Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p><a href="http://developer.android.com/reference/android/media/MediaPlayer.html#setNextMediaPlayer%28android.media.MediaPlayer%29" rel="nofollow">setNextMediaPlayer</a>() was added in API level 16 for that purpose.<br> If your target is above API 16, this should do the job.<br> If your target is below API 16, the following can work.<br> In one my projects, I did it just using MediaPlayer().<br> In that case, I set <code>setDataSource</code>() in <code>onCompletion(){};</code> without inializing the MediaPlayer again.</p> <pre><code>public class Player extends Activity implements OnCompletionListener, MediaPlayer.OnPreparedListener, SurfaceHolder.Callback { private MediaPlayer player; private SurfaceView surface; private SurfaceHolder holder; public void onCreate(Bundle b) { super.onCreate(b); setContentView(R.layout.main); surface = (SurfaceView)findViewById(R.id.surface); holder = surface.getHolder(); holder.addCallback(this); holder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS); playVideo(firstUrl); } public void onCompletion(MediaPlayer arg0) { playVideo(nextClipUrl); } public void onPrepared(MediaPlayer mediaplayer) { holder.setFixedSize(player.getVideoWidth(), player.getVideoHeight()); player.start(); } private void playVideo(String url) { try { if (player == null) { player = new MediaPlayer(); player.setScreenOnWhilePlaying(true); } else { player.stop(); player.reset(); } player.setDataSource(url); player.setDisplay(holder); player.setOnPreparedListener(this); player.prepare(); player.setOnCompletionListener(this); } catch (Throwable t) { Log.e("ERROR", "Exception Error", t); } } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload