T
T
trollface2013-01-30 23:04:04
Java
trollface, 2013-01-30 23:04:04

MediaPlayer not working?

Good day!
I have a simple code running in an IntentService.

MediaPlayer mp = new MediaPlayer();

mp.setDataSource(audio.url); 
mp.prepare();
mp.start();

(All try and catch are present.)
This code works fine starting with Android 4.0
And on versions below, calling the strart () method does nothing. (although you can get, for example, the duration of the track (i.e., the preparation went well)
It doesn’t write anything in the logs.
I searched the entire Internet, tried different methods - nothing helps (
One hope for you ...

Answer the question

In order to leave comments, you need to log in

1 answer(s)
O
Oleg, 2014-12-26
@Master255

Weird. The start was always in onprepared.

videoView.setOnPreparedListener(new OnPreparedListener()
      {
        public void onPrepared(MediaPlayer mp)
        {
                                          videoView.start();  //именно videoView а не mp. Хоть и очень хочется.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question