I am developing a small android application in which i am playing the rtsp link using android media player .It is working properly on less then android 16 api. but the problem is that when i run on android 16 it take lots of time to play and some time it even does not play.following is the code which I am using
sdrPlayer = new MediaPlayer();
sdrPlayer.setDataSource(url);
sdrPlayer.prepare();
sdrPlayer.setOnCompletionListener(video.this);
sdrPlayer.setOnPreparedListener(video.this);
sdrPlayer.setOnBufferingUpdateListener(video.this);
sdrPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
Following are some test case
onprepare
method but there is no audio.for playing rtsp link you should use sdrPlayer.prepareAsync();
instead of
sdrPlayer.prepare();
because the documentation says
It prepares the player for playback, asynchronously. After setting the datasource and the display surface, you need to either call prepare()
or prepareAsync()
. For streams, you should call prepareAsync()
, which returns immediately, rather than blocking until enough data has been buffered.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With