I have an application on Google Play that streams music from a radio station built with the latest cordova (5.4) and I am using some of the basic plugins such as:
device plugin
crosswalk webview plugin
dialogs plugin
...
files plugin
media plugin
On Android 5.0+ the streaming works fine but recently when I upgraded my nexus on android 6.0 the streaming stopped. I updated media and file plugin to the latest versions (2.0.0 and 4.0.0 respectively), as cordova stated in their blog that these versions support the new permission checking on Android 6 but still the streaming is not working. The log gives me this:
11-24 23:53:35.347 15184-15184/com.uni.app E/chromium: [ERROR:xwalk_autofill_client.cc(170)] Not implemented reached in virtual void xwalk::XWalkAutofillClient::OnFirstUserGestureObserved()
11-24 23:53:40.395 15184-15235/com.uni.app D/MediaPlayer: setSubtitleAnchor in MediaPlayer
11-24 23:53:40.410 15184-15235/com.uni.app W/MediaPlayer: Stream has no duration and is therefore not seekable.
11-24 23:53:40.410 15184-15235/com.uni.app E/MediaPlayer: error (-2147483648, 0)
11-24 23:53:40.410 15184-15235/com.uni.app D/AudioPlayer: Send a onStatus update for the new seek
11-24 23:53:40.410 15184-15235/com.uni.app W/CordovaPlugin: Attempted to send a second callback for ID: Media951412725 Result was: {"action":"status","status":{"id":"d5334ff7-5511-ea09-b2ef-2900789941a9","msgType":3,"value":0}}
11-24 23:53:40.411 15184-15235/com.uni.app E/MediaPlayer: start called in state 0
11-24 23:53:40.411 15184-15235/com.uni.app E/MediaPlayer: error (-38, 0)
11-24 23:53:40.412 15184-15235/com.uni.app W/CordovaPlugin: Attempted to send a second callback for ID: Media951412725 Result was: {"action":"status","status":{"id":"d5334ff7-5511-ea09-b2ef-2900789941a9","msgType":1,"value":2}}
11-24 23:53:40.412 15184-15235/com.uni.app E/MediaPlayer: Attempt to call getDuration without a valid mediaplayer
11-24 23:53:40.412 15184-15235/com.uni.app E/MediaPlayer: error (-38, 0)
11-24 23:53:40.412 15184-15235/com.uni.app W/CordovaPlugin: Attempted to send a second callback for ID: Media951412725 Result was: {"action":"status","status":{"id":"d5334ff7-5511-ea09-b2ef-2900789941a9","msgType":2,"value":314586.9375}}
11-24 23:53:40.413 15184-15235/com.uni.app E/MediaPlayer: Error (-2147483648,0)
11-24 23:53:40.413 15184-15235/com.uni.app D/AudioPlayer: on completion is calling stopped
11-24 23:53:40.414 15184-15235/com.uni.app W/CordovaPlugin: Attempted to send a second callback for ID: Media951412725 Result was: {"action":"status","status":{"id":"d5334ff7-5511-ea09-b2ef-2900789941a9","msgType":1,"value":4}}
11-24 23:53:40.414 15184-15235/com.uni.app E/MediaPlayer: Error (-38,0)
11-24 23:53:40.414 15184-15235/com.uni.app D/AudioPlayer: on completion is calling stopped
11-24 23:53:40.414 15184-15235/com.uni.app E/MediaPlayer: Error (-38,0)
11-24 23:53:40.414 15184-15235/com.uni.app D/AudioPlayer: on completion is calling stopped
11-24 23:53:53.476 15184-15184/com.uni.app E/chromium: [ERROR:xwalk_autofill_client.cc(170)] Not implemented reached in virtual void xwalk::XWalkAutofillClient::OnFirstUserGestureObserved()
11-24 23:53:58.409 15184-15232/com.uni.app E/Surface: getSlotFromBufferLocked: unknown buffer: 0xaed05f70
11-24 23:53:58.419 15184-15184/com.uni.app W/ScreenOrientationListener: Removing an inexistent observer!
11-24 23:53:58.419 15184-15184/com.uni.app E/chromium: [ERROR:runtime_javascript_dialog_manager.cc(69)] Not implemented reached in virtual void xwalk::RuntimeJavaScriptDialogManager::ResetDialogState(content::WebContents*)
11-24 23:53:58.453 15184-15184/com.uni.app D/AudioPlayer: renaming /storage/emulated/0/tmprecording.3gp to /storage/emulated/0/http://IPADDRESS:PORT/;
11-24 23:53:58.454 15184-15184/com.uni.app E/AudioPlayer: FAILED renaming /storage/emulated/0/tmprecording.3gp to /storage/emulated/0/http://IPADDRESS:PORT/;
11-24 23:53:58.465 15184-15197/com.uni.app E/Surface: getSlotFromBufferLocked: unknown buffer: 0xb3978f90
IPADDRESS:PORT is a real http://ipaddress:port URL stream which works fine.
I now it has to do with the permissions but still no luck on finding exactly what. Going on app-info and on new permissions menu I see that the app uses Microphone, Phone and Storage permissions which are all enabled. I searched a lot and couldn't be able to find something similar.
Any help is appreciated
I found the problem, just comment this line on AudioPlayer.java
public void onPrepared(MediaPlayer player) {
// Listen for playback completion
this.player.setOnCompletionListener(this);
// seek to any location received while not prepared
//this.seekToPlaying(this.seekOnPrepared);
// If start playing after prepared
if (!this.prepareOnly) {
this.player.start();
this.setState(STATE.MEDIA_RUNNING);
this.seekOnPrepared = 0; //reset only when played
} else {
this.setState(STATE.MEDIA_STARTING);
}
// Save off duration
this.duration = getDurationInSeconds();
// reset prepare only flag
this.prepareOnly = true;
// Send status notification to JavaScript
sendStatusChange(MEDIA_DURATION, null, this.duration);
}
Checked on Github in the official repo and found this
Tried on a new sample app and worked fine on my Android 6.0 device. The solution is close to what luckakashi suggested with some extra commenting.
Seems something wrong from Crosswalk, have you try if you remove the Crosswalk plugin? And is your Android 6.0 device 64-bit?
Related
I'm trying to play video from the URL. Everything seems fine in the first few minutes, but then it crashes and the message "Can't Play Video" occurs. My code:
videoView.setVisibility(View.VISIBLE);
videoView.setVideoPath(url);
videoView.setMediaController(mediaController);
videoView.seekTo(time);
videoView.start();
Logcat:
2020-04-03 22:02:29.572 25409-25409/com.modyf.anime_app W/InputTransport: Slow Input: 152ms so far, channel 'ClientState{7a1b727 uid 10348 pid 25409} (server)' publisher ~ publishKeyEvent: seq=1, deviceId=4, source=0x101, action=0x0, flags=0x8, keyCode=25, scanCode=114, metaState=0x0, repeatCount=0,downTime=101580658000000, eventTime=101580658000000
2020-04-03 22:03:54.751 25409-25421/com.modyf.anime_app W/MediaHTTPConnection: readAt 25214561 / 16799 => java.net.ProtocolException: unexpected end of stream
2020-04-03 22:05:11.419 25409-25421/com.modyf.anime_app W/MediaPlayerNative: info/warning (804, -1004)
2020-04-03 22:05:11.475 25409-25422/com.modyf.anime_app E/MediaPlayerNative: error (1, -1004)
2020-04-03 22:05:11.476 25409-25409/com.modyf.anime_app E/MediaPlayer: Error (1,-1004)
2020-04-03 22:05:11.476 25409-25409/com.modyf.anime_app D/VideoView: Error: 1,-1004
2020-04-03 22:05:11.604 25409-25439/com.modyf.anime_app W/Adreno-EGL: <qeglDrvAPI_eglGetConfigAttrib:612>: EGL_BAD_ATTRIBUTE
2020-04-03 22:05:11.606 25409-25439/com.modyf.anime_app D/vndksupport: Loading /vendor/lib64/hw/gralloc.msm8937.so from current namespace instead of sphal namespace.
Im coding an player application for Android Tv.
While testing to play videos on a nexus player device the VideoView (that is a wrapper of MediaPlayer) is giving me some strange error codes that are not documented at all in the api references.
My nexus player is api 23 (android M) and i also target api 23 in my app.
Here is the log:
10-21 15:42:59.234 29145-29145/com.test.androidapp D/MediaPlayer: getMetadata
10-21 15:42:59.259 29145-29734/com.test.androidapp E/MediaPlayer: error (1, -2147479543)
10-21 15:42:59.260 29145-29262/com.test.androidapp E/MediaPlayer: error (1, -38)
10-21 15:42:59.265 29145-29145/com.test.androidapp E/MediaPlayer: Error (1,-2147479543)
10-21 15:42:59.265 29145-29145/com.test.androidapp D/VideoView: Error: 1,-2147479543
I am building an audio streaming app. Here is the code I use to launch the media player:
Intent intent = new Intent();
intent.setAction(android.content.Intent.ACTION_VIEW);
intent.setDataAndType(Uri.parse("http://wunh.org:8000/"), "audio/*");
startActivity(intent);
The code works fine on my Droid phone (Android 2.3.4) - it brings up the phone media player and plays the station...
But it does not work on Nexus 7 (Android 4.2) - both "Google play music" and "Video player" fail with the same error code:
12-04 11:49:25.373: E/MediaPlayer(13331): Error (1,-1004)
UPD: here is all related logcat entries:
12-04 14:04:21.573: D/MediaPlayer(17933): Couldn't open file on client side, trying server side
12-04 14:04:21.573: I/AwesomePlayer(128): setDataSource_l(URL suppressed)
12-04 14:04:21.583: V/ChromiumHTTPDataSource(128): connect on behalf of uid 10036
12-04 14:04:21.583: I/ChromiumHTTPDataSource(128): connect to <URL suppressed> #0
12-04 14:04:21.633: I/ActivityManager(481): Displayed com.google.android.music/.AudioPreview: +83ms
12-04 14:05:24.733: I/ChromiumHTTPDataSourceSupport(128): Request failed with status 4 and os_error -118
12-04 14:05:24.733: I/AwesomePlayer(128): mConnectingDataSource->connect() returned -1004
12-04 14:05:24.733: E/MediaPlayer(17933): error (1, -1004)
12-04 14:05:24.733: E/MediaPlayer(17933): Error (1,-1004)
Any suggestions will be greatly appreciated.
-Dmitry
AsyncPlayer? http://developer.android.com/reference/android/media/AsyncPlayer.html
AsyncPlayer ap=new AsyncPlayer("Player");
ap.play(this, Uri.parse(url), true, AudioManager.STREAM_MUSIC);
I am working on an android app and i want to play streaming video from youtube. I read posts like this: How to play YouTube video in my Android application?
I tried with that source:
startActivity(new Intent(Intent.ACTION_VIEW,Uri.parse("http://www.youtube.com/watch?v=tsDYIgX_gDs")));
i got video in WebView, i can heard sound but no pictures..Also that is not what i want because i want video to start automatically when the activity start, without clicking Button play(because i want also to add some counters,timers.. for other treatments).
Then, i tried whith MediaPlayer:
String FILE_PATH="http://www.youtube.com/watch?v=tsDYIgX_gDs";
MediaPlayer mp = new MediaPlayer();
mp.setDataSource(FILE_PATH);
mp.prepare();
mp.start();
Hopping here having a control on video start by mp.start(); . But i have these errors:
05-20 15:36:36.279: ERROR/HTTPStream(33): recv failed, errno = 11 (Try again)
05-20 15:36:36.808: ERROR/HTTPDataSource(33): HTTP request failed w/ http status 303
05-20 15:36:36.808: ERROR/HTTPDataSource(33): retrying connection failed
05-20 15:36:41.834: ERROR/HTTPStream(33): recv failed, errno = 11 (Try again)
05-20 15:36:48.389: ERROR/HTTPStream(33): recv failed, errno = 11 (Try again)
05-20 15:36:54.913: ERROR/HTTPStream(33): recv failed, errno = 11 (Try again)
05-20 15:36:54.913: ERROR/HTTPStream(33): recv failed, errno = 9 (Bad file number)
05-20 15:36:54.918: ERROR/HTTPStream(33): recv failed, errno = 9 (Bad file number)
05-20 15:36:54.918: ERROR/HTTPStream(33): recv failed, errno = 9 (Bad file number)
05-20 15:36:54.918: ERROR/MediaPlayer(6392): error (1, -2147483648)
05-20 15:36:55.219: ERROR/MediaPlayer(6392): start called in state 0
05-20 15:36:55.219: ERROR/MediaPlayer(6392): error (-38, 0)
05-20 15:36:55.228: ERROR/MediaPlayer(6392): Error (-38,0)
Can someone help plz?
Try changing the Start intent to :
startActivity(new Intent(Intent.ACTION_VIEW,
Uri.parse(String.format("http://www.youtube.com/v/%s",
url.substring("vnd.youtube:".length(),n)));
For deeper learning try out the following question : This, and This.
I am using the MediaPlayer to play some .mp3 files. The files seem to
play correctly, however, every time I play one I see the following in
LogCat:
07-17 17:30:40.298: VERBOSE/SongPath(294): Songlist/data/data/com.bluepallabs.musicbank/haihai/Oopirage.mp3
07-17 17:30:40.387: WARN/MediaPlayer(294): info/warning (1, 26)
07-17 17:30:40.418: ERROR/PlayerDriver(30): Command PLAYER_SET_DATA_SOURCE completed with an error or info PVMFErrNotSupported
07-17 17:30:40.418: ERROR/MediaPlayer(294): error (1, -4)
07-17 17:30:40.427: WARN/PlayerDriver(30): PVMFInfoErrorHandlingComplete
07-17 17:30:40.518: INFO/MediaPlayer(294): Info (1,26)
07-17 17:30:40.528: ERROR/MediaPlayer(294): Error (1,-4)
As I am playing the above songpath in emulator.I am getting issue please provide any code avaible to solove this issue.
As I am using the code as:
player.reset();
songpath=/data/data/com.bluepallabs.musicbank/haihai/Oopirage.mp3
player.setDataSource(SongPath);
player.prepareAsync();
Thnak in advance.
teja
info/warning(1,26) is just a notification that error handling has started.
error(1, -4) is an Error due to the request not being supported
Try making your songpath a String then passing it into the media player like:
player.reset();
String songpath = "/data/data/com.bluepallabs.musicbank/haihai/Oopirage.mp3"
player.setDataSource(songpath);
player.prepareAsync();