MediaPlayer pause called in state 8 when player is playing - android

I'm desperate, I work with MediaPlayer and I would just pause the player.
But when I try to pause the player, I got error (-38, 0).
And in log : pause called in state 8.
I know this error would mean I try to pause the player when it isn't started. But my code is :
if (mediaMusic.isPlaying()) {
Log.d("GREG", "Media music is playing");
mediaMusic.pause();
Log.e("GREG", "Media music paused");
}
But in logs :
D/GREG: Media music is playing
V/MediaPlayer-JNI: pause
V/MediaPlayer: pause
E/MediaPlayer: pause called in state 8, mPlayer(0x7546266e00)
V/MediaPlayer: message received msg=100, ext1=-38, ext2=0
E/MediaPlayer: error (-38, 0)
V/MediaPlayer: callback application
V/MediaPlayer: back from callback
E/GREG: Media music paused
So if somebody has an idea to resolve this issue it will be beautiful !
Thanks !
EDIT : I've just see the problem is only present when I set the speed of MediaPlayer like that
mediaMusic.setPlaybackParams(mediaMusic.getPlaybackParams().setSpeed(rate));
But I have to change the speed, so the problem is still unsolved ...

Related

Android weird black videoview + errors on real world device, not in emulator

So, I have an app that I'm trying to get to loop a bunch of video portraits at the bottom. It works perfectly on the emulator (Android 4.1) and seemed to work on my phone (7.1).
On the device I need to deploy the app to (an old android 4.0 TV box) the videos appear black, or start showing something and then go to black shortly after.
I tried an emulator of 4.0 and it seems to be doing the same thing, but I can't figure out why and searches for the error codes it's shooting out don't pull up anything.
It loops through all the portraits and creates video views like this:
`
VideoView video = new VideoView(context);
boolean failure = false;
Log.d("videoPlayer", "Playing video: " + Environment.getExternalStorageDirectory()+"/reviews/" + localPortraits[i]);
video.setVideoPath(Environment.getExternalStorageDirectory()+"/reviews/" + localPortraits[i]);
video.setOnErrorListener(new MediaPlayer.OnErrorListener(){#Override
public boolean onError(MediaPlayer nmp, int what, int extra){
Log.d("MediaPlayer", "CAUGHT ERROR. ReDownload");
badMovie(nmp.toString());
return true;
}
});
video.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
#Override
public void onPrepared(MediaPlayer mp) {
mp.start();
mp.setLooping(true);
}
});
frame.addView(video);
}`
And again, running in the 4.1 emulator it works beautifully. When I put it on the 4.0 TV or 4.0 emulator, it shoots out this:
W/MediaPlayer: info/warning (8004, 0)
I/MediaPlayer: Info (8004,0)
W/MediaPlayer: info/warning (8004, 0)
I/MediaPlayer: Info (8004,0)
W/MediaPlayer: info/warning (8004, 0)
I/MediaPlayer: Info (8004,0)
I/VideoView: MediaPlayer:AMLOGIC_PLAYER Prepared
D/MediaPlayer: getMetadata
I/VideoView: Layout changed,left=3 top=3 right=80 bottom=140
I/VideoView: Layout changed,oldLeft=3 oldTop=3 oldRight=81 oldBottom=140
I/VideoView: .left=3.top=3.right=80.bottom=140.oldLeft=3.oldTop=3.oldRight=81.oldBottom=140.Rotation=0
I/VideoView: MediaPlayer:AMLOGIC_PLAYER Prepared
D/MediaPlayer: getMetadata
E/MediaPlayer: error (1, -33554484)
E/MediaPlayer: error (1, -1)
I/VideoView: MediaPlayer:AMLOGIC_PLAYER Prepared
D/MediaPlayer: getMetadata
E/MediaPlayer: error (1, -33554484)
E/MediaPlayer: error (1, -1)
Plus a ton more along the same lines.
What am I doing wrong that it won't run on Android 4.0?

Android MediaPlayer error (1, -19)

I am working on an app in which an audio file (boo.wav) is being played. The audio does however not play and generates some error output.
When trying to execute the following line:
MediaPlayer.create(this, R.raw.boo).start();
I get the following errors:
E/MediaPlayer﹕ Should have subtitle controller already set
E/MediaPlayer﹕ error (1, -19)
E/MediaPlayer﹕ Should have subtitle controller already set
E/MediaPlayer﹕ Error (1,-19)
Can someone point me in a general direction as to what I am doing wrong?

Android Media Player - 903 warning

I have a problem with video not been playing. I am using SurfaceView with MediaPlayer.
Those are my actions:
MediaPlayer.setDataSource(url)
MediaPlayer.prepareAsync();
MediaPlayer.start() // From setOnPreparedListener listener
MediaPlayer.reset()
Go back to 1 with different url
About 3 out of 5 videos do not start playing. I see nothing in the logs except some times when video does start it show me this:
W/MediaPlayer﹕ info/warning (1, 903)
Can't find 903 in the documentations.

MediaPlayer mutes after some minutes of playing mp3

I'm developing an AudioBook player for Android. For the playing part, I've used MediaPlayer class which works perfectly for some minutes but then always suddenly fails and no voice could be heard.
Even if I stop and issue a new request (read new chapter) it doesn't work. However the passing of time seems natural (for example playing a 10 seconds clip takes 10 seconds to finish) but there is absolutely no voice!
Does someone have any clues what might cause this problem?
Here's the relevant parts of my MediaPlayer usage.
And here's the logcat around the place it mutes.
EDIT:
By analyzing the logcat, I found out that this part is showing after the muting has happened:
E/AudioFlinger( 146): no more track names available
E/AudioTrack( 146): AudioFlinger could not create track, status: -12
E/AudioSink( 146): Unable to create audio track
E/AwesomePlayer( 146): deleting Audio Player - start failed
E/MediaPlayer( 5558): error (-19, 0)
***V/MainActivity( 5558): onNewPage()
E/MediaPlayer( 5558): Error (-19,0)
E/Sensors ( 285): sensors_poll_context_t::pollEvents, line 202: receive event #### i=2, nb=0
E/Sensors ( 285): sensors_poll_context_t::pollEvents, line 202: receive event #### i=2, nb=0
E/Sensors ( 285): sensors_poll_context_t::pollEvents, line 202: receive event #### i=2, nb=0
E/Sensors ( 285): sensors_poll_context_t::pollEvents, line 202: receive event #### i=2, nb=0
***V/MediaPlayerWrapper( 5558): stop()
***D/MediaPlayerWrapper( 5558): Stopping player...
E/MediaPlayer( 5558): stop called in state 0
E/MediaPlayer( 5558): error (-38, 0)
The lines with three * at beginning are my messages, others are frameworks'.
The problem was simply because of not releasing the media player object; as these answers (a,b,c) suggested already.
mMediaPlayer.release();

android media player - PVMFFailure on mp3 http radio stream

I want to play mp3 radio stream using Android MediaPlayer via http protocol. From time to time [1 playing of 5 - that is actually quite often] I receive PVMFFailure like this:
02-23 02:05:23.503: ERROR/PlayerDriver(91): Command PLAYER_INIT completed with an error or info PVMFFailure
02-23 02:05:23.503: ERROR/MediaPlayer(2111): error (1, -1)
02-23 02:05:23.533: ERROR/MediaPlayer(2111): stop called in state 0
02-23 02:05:23.533: ERROR/MediaPlayer(2111): error (-38, 0)
There is no solution here or on google, so please if you do know how to debug this, please help :)
Here is my code for player:
//start
MediaPlayer player = new MediaPlayer();
player.setAudioStreamType(AudioManager.STREAM_MUSIC);
player.setDataSource(address);
player.prepare();
player.start();
//stop
player.stop();
player.reset();
I`m using Android 2.2 API. Thanks!
You should use player.prepareAsync(); instead player.prepare();.

Categories

Resources