Any clues about MediaPlayer Info/Warning 950? - android

I've been playing some mp4 videos through the VideoView, which apparently uses/is a wrapper for the MediaPlayer.
As usual I see the typical ones in the logcat:
I/MediaPlayer﹕ Info (701,0)
I/MediaPlayer﹕ Info (702,0)
But then I see that one as well:
I/MediaPlayer﹕ Info (950,0)
As stated in this answer and others questions, most 9XX MediaPlayer Info/Warning/Error codes aren't officially documented in the SDK docs, but probably is related with "timed text tracks" (subtitles), since the only references to 9XX are MEDIA_INFO_UNSUPPORTED_SUBTITLE (901) and MEDIA_INFO_SUBTITLE_TIMED_OUT (902).
The thing is, I don't use any subtitles or external/extra resources while playing the video, so that would be strange.
Does anyone know any additional information about the 950 or the 9XX codes?
(I'm trying to track a bug that could be related to that since it's the last info I have going in the logcat - just exploring all the possibilities.)

Am facing the same warning but with a different scenario. In the following code, resetting the mediaplayer after onCompletion generates this warning. After it I have problems with the track and trying to restart it.
soundMediaPlayer.setOnCompletionListener(new MediaPlayer.OnCompletionListener() {
#Override
public void onCompletion(MediaPlayer mediaPlayer) {
mediaPlayer.reset();
mediaPlayer = MediaPlayer.create(MainActivity.this, soundUri);
mediaPlayer.start();
}
});
Hope it gives you a clue.

Related

What means the message "internal/external state mismatch corrected" at the MediaPlayer?

I work with a MediaPlayer and set the state of the player often programmatically like for example:
if(mp.isPlaying()) {
mp.pause();
animationPausedMusic();
}
private void animationPausedMusic() {
// Changing button image to play button
btn_play.setBackgroundResource(R.drawable.play);
... // more code
}
But sometimes the logcat gives me the message:
"internal/external state mismatch corrected"
And then the play and pause function is not working anymore.
What does this message mean? And how can I solve it?
After going through the android's native framework for media player I found that in source file mediaplayer.cpp inside function bool MediaPlayer::isPlaying() The developer is checking if the currentState of media player is in STARTED state and yet the media player is not playing any media, so it tries to change the state to PAUSED state so that the state consistency should be maintained for API users.(and here is where he is printing the message "ALOGE("internal/external state mismatch corrected");")
Now If you go through the media player state diagram below:
You would notice that this may happen when the MediaPlayer moved to 'STARTED' state after a call to start() and at this time for some obscure reason has not yet started the playback and you fire a MediaPlayer.isPlaying() method call , The Framework treat this as state inconsistency and moves to 'PAUSED' state and that's why you cannot see anything playing further.
However, if someone has some better understanding please share your thoughts!
I ran into this recently, and like some other questions say, it's this bug (marked obsolete alas)
https://code.google.com/p/android/issues/detail?id=9732
I found this error occurs when playing a MIDI file, but only sometimes. It happens when mp.isPlaying() is called quickly after mp.start()
If you can manage to not call mp.isPlaying() for a little bit, the error doesn't occur. In my case, a 10th of a second or so made the difference between getting the error or not. It's awkward, but it works.
e.g.
//setting a new track
mp.setDataSource(path);
mp.prepare();
mp.start();
//calling mp.isPlaying() here or shortly after starts the problem
//since we know it's playing, we can store that state, or call
updateUiPlaying(); //eg instead of updateUi();
//or just call some code here that takes more time first
updateScaledImages(); //something that might take time
Log.v(TAG, "mp.isPlaying = " + mp.isPlaying()); //now isPlaying() shouldn't cause that error
Also, I put a check in when I pause later.
mp.pause()
if(mp.isPlaying()){
//shouldn't be playing, must be in error
mp.stop();
mp.release();
mp = new MediaPlayer();
//any other initialization here
}
Though the problem doesn't occur if there is a wait before calling isPlaying()
Apparently there is more than one cause of this message. The following solution worked for me. It may or may not work for you. I called the method MediaPlayer.reset() immediately after instantiating the MediaPlayer object:
MediaPlayer mp = new MediaPlayer();
mp.reset();

Unclear error when playing a video in a VideoView

I'm trying to play a video (by a uri) in a VideoView and sometimes get the following errors:
E/MediaPlayer(15861): error (1, -2147483648)
D/MediaPlayer(15861): Couldn't open file on client side, trying server side
W/MediaPlayer(15861): mediaplayer went away with unhandled events
I found that the "list" of codes can be found in the following source code:
https://github.com/android/platform_external_opencore/blob/master/pvmi/pvmf/include/pvmf_return_codes.h
(thanks to the thread Complete list of MediaPlayer error codes)
But that does not make things more clear, there's nothing there about -2147483648, and the 1 I get is positive and in this source it says that error codes are negative.
Same thing was reported in this thread: Playing youtube video in a videoview, though he did not ask about what this error means (nor did he get any helping answer).
Anyone has an idea of the meaning of this error?
Thanks.
Edit
I'm trying to show youtube videos, the url of the stream is taken from http://www.youtube.com/get_video_info?&video_id=VIDEO_ID and it's being done asynchronously.
When the result gets back, this is the code I'm using:
activity.runOnUiThread(new Runnable() {
#Override
public void run() {
setVideoURI(videoStream);
}
});
This is being executed by a class which extends VideoView.
1 stand for MEDIA_ERROR_UNKNOWN. and -2147483648 is a myth
Refer to the documentation for further details.
This kind of error occurs when trying to play an invalid url. Assuming you are not using third party libraries.

How to play a song using service?

I want to know, how to run a song in a service, I also want to use .aidl file to expose clients the interface.
Sound basic for Android..
I recommended you for go through this tutorial MusicDroid - Audio Player Part.
There are three parts of these tutorial. Its nicely describe for how to implement Audio player for android using service and AIDL.
Also look at this android developer tutorial Media Playback.
I think this will help you a lot..!
I assume you know how to create a service, I did something before similar
import android.media.MediaPlayer;
private MediaPlayer mMediaPlayer;
private void play() {
mMediaPlayer = new MediaPlayer();
mMediaPlayer.setDataSource(getSongUrl());
mMediaPlayer.prepare();
mMediaPlayer.start();
}
when interact with UI, send Intent from the UI to the service so that you can do let pause:
mMediaPlayer.pause();
or seek to certain time:
mMediaPlayer.seekTo((int) (to * mMediaPlayer.getDuration()));
and remember make sure call the release()
Please check the class here: http://developer.android.com/reference/android/media/MediaPlayer.html

VideoView looping videos Replenish

I have an application with a VideoView that will keep looping the same video over and over until a user does something to the device(touch screen, etc) Currently I am using the OnCompletionListener() to restart the video once it ends. This works properly on every device I have tested, except for the Samsung Replenish.
Here is my code:
mVideoView.setOnCompletionListener(new MediaPlayer.OnCompletionListener() {
public void onCompletion(MediaPlayer mp) {
mVideoView.setVideoPath(file.getAbsolutePath());
mVideoView.start();
}
});
What happens on the Replenish is the video plays all the way through once but then is never started again and the screen goes all black (But backlight still turned on). On every other device I've tested on with this exact same code it has worked to repeat the video. Does anyone know of anything specific about the Replenish that could cause this error? I thought maybe delaying the calls to setVideoPath(), and start() by 200-300ms might help it, but that had no affect. I am really at a loss here.
I am seeing these messages in my Log:
ERROR/QCvdec(87): Omx Flush issued when vdec is not initialized yet.
ERROR/QCvdec(87): OMXCORE-SM:Recieved command DISABLE (2)
ERROR/QCvdec(87): Omx Flush issued when vdec is not initialized yet.
ERROR/QCvdec(87): OMXCORE-SM:Recieved command ENABLE (3)
But these logs are happening both when the video starts (the first time it plays) and when it fails to start again. so I am not sure if they are related to my problem
Edit:
I just tried setting mVideoView to null, and then getting a new reference to it with findViewById() right before the setVideoPath(). I know this would complicate the way the OnCompletionListener is set up. But regardless of that it didn't work anyway, still the same dark screen.
Edit 2:
I've started to notice that sometimes the video doesn't even start the first time. I am using these same two lines to start it up the first time:
mVideoView.setVideoPath(file.getAbsolutePath());
mVideoView.start();
It seems to start more consistantly, but not quite 100% when its the first time it is being played.
Edit 3: This is how I have it set up now. I am manually setting the OnPreparedListener to start the video for me. So I added this to my onCreate()
mVideoView.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
#Override
public void onPrepared(MediaPlayer arg0) {
mVideoView.start();
}
});
Then when I am ready to restart the video I just call only the setVideoPath() method, Like this:
mVideoView.setOnCompletionListener(new MediaPlayer.OnCompletionListener() {
public void onCompletion(MediaPlayer mp) {
mVideoView.setVideoPath(file.getAbsolutePath());
}
});
This seems to be doing the trick. I am letting it run for a while to find out for sure though.
Edit 4:
#MByD In the code for VideoView setVideoPath() is a wrapper for setVideoUri(). setVideoURI() is setting mStartWhenPrepared = false; The default OnPreparedListener checks this switch to decide whether to start playback or not. That is why it doesn't start with the default listener. I haven't looked into it more than that, but there may be a setter method that lets me change the mStartWhenPrepared value to true, which would cause the video to be started from the default listener.
Have you tryed to prepare() your video before you call .start()?
from the docs: http://developer.android.com/reference/android/media/MediaPlayer.html#prepare%28%29
with a OnPreparedListener you can start your video when its ready.

Regarding IllegalStateExceptions, MediaPlayer, failed prepares and State codes

I have been struggling quite a lot with our beloved MediaPlayer class...
Specifically I want to simply play sounds from some Files...
I am getting two specific types of errors actually, and not continuesly but it seems like random... Sometimes 10 files are played rigth away with no errors, then the MediPlayer seems to stop accepting another File...
Ok the first error :
- 05-26 15:02:00.916: ERROR/MediaPlayer(25793): error (1, -4)
- 05-26 15:02:00.916: ERROR/setupplayer(25793): java.io.IOException: Prepare failed.: status=0x1
Well for this one I have seen several solutions :
use
mp.setDataSource(ins.getFD()); (with ins being an inputstream to my File)
and/or to use
mp.setDataSource(ins.getFD(), 0, f.length());
Both unfortunately won't solve the problem, and I would simply LOVE to know what the very exhaustive error(1,-4) is... And where can I find the codes of the States of the MediaPlayer ?
Also I have tried using prepareAsync() instead of prepare() but to be honest it doesn't seem to make any difference at all..
The second error is the Exception which is thrown :
05-26 15:17:30.456: ERROR/playNextPlayer(27303): Error caught : java.lang.IllegalStateException
Which, I guess, might be related to the first error/problem ?
Try mp.setDataSource(String path)
For example,mp.setDataSource("sdcard/1.mp3");
The error is coming because of incorrect path or FileDescriptor.
You should check the State Diagram of Mediaplayer class

Categories

Resources