android media player - PVMFFailure on mp3 http radio stream - android

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();.

Related

MediaPlayer pause called in state 8 when player is playing

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 ...

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 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 Shoutcast: Want help to play ShoutCast Streaming in 1.6

My application plays ShoutCast Streaming and the target OS is 1.6 and above. I have applied some code from NPR application with some modification.
Here is the code
mediaPlayer = new MediaPlayer();
mediaPlayer.reset();
mediaPlayer.setDataSource(url);
mediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
// Log.d(LOG_TAG, "Preparing: " + playUrl);
mediaPlayer.prepareAsync();
mediaPlayer.start();`
The code doesnot play anything on simulator or device(Testing in Samsung Galaxy with 2.1).
Here is the LogCat message.
About to play http://88.191.81.31:8206
12-08 14:16:42.229: WARN/MediaPlayer(5520): info/warning (1, 26)
12-08 14:16:42.239: ERROR/PlayerDriver(1870): Command PLAYER_INIT completed with an error or info PVMFFailure
12-08 14:16:42.239: ERROR/MediaPlayer(5520): error (1, -1)
12-08 14:16:42.239: WARN/PlayerDriver(1870): PVMFInfoErrorHandlingComplete
12-08 14:16:42.259: ERROR/MediaPlayer(5520): start called in state 0
12-08 14:16:42.259: ERROR/MediaPlayer(5520): error (-38, 0)
12-08 14:16:42.299: INFO/MediaPlayer(5520): Info (1,26)
12-08 14:16:42.299: ERROR/MediaPlayer(5520): Error (1,-1)
12-08 14:16:42.304: ERROR/MediaPlayer(5520): Error (-38,0)
Here is the question. 1. Can you tell me whats happening in device? 2. How to solve this error?.
You are calling start() too soon. Javadocs of MediaPlayer explain it (look at the picture):
Either you have to call prepare() before you call start(), or
You call prepareAsync() and wait for OnPreparedListener.onPrepared() to be called, then (possibly inside this method) call start().
Updated:
Shoutcast streams are nativelly supported only on 2.2. For earlier versions you must create local proxy that changes the response protocol from ICY (shoutcast) to HTTP, which the
mediaplayer will support. Take a look at this:
http://code.google.com/p/npr-android-app/source/browse/trunk/Npr/src/org/npr/android/news/StreamProxy.java
This has previously been discussed:
Listen to a shoutcast with Android

Categories

Resources