Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>You need to pay more attention to the <code>MediaPlayer</code>'s <a href="http://developer.android.com/reference/android/media/MediaPlayer.html" rel="nofollow">state machine</a> and design your interaction with it more carefully around that. To be specific, you cannot call <code>release</code> in the completion callback and expect to be able to use the same <code>MediaPlayer</code> again.</p> <p>You can instead call <code>reset</code> in the completion callback and go through the code you have in <code>initializeMediaPlayer</code> again. Or alternatively, you can try seeking to zero to avoid re-preparing the source (although preparing a local file is negligible in terms of performance).</p> <p>Edit: About your <code>MediaController</code> problem... it can be a bit wonky in the emulator. I have a few suggestions.</p> <p>1) Basically never use <code>getApplicationContext()</code>, especially not from inside an <code>Activity</code> (which already is a <code>Context</code>). (This probably doesn't help get the controller to show, but is just a general tip.)</p> <p>2) You are passing <code>R.layout.activity_main</code> to <code>findViewById</code>. I don't think that's correct. It should be <code>R.id.___</code> for the ID of a view defined inside the layout. You can define the IDs with the <code>android:id</code> tag in the layout XML.</p> <p>3) I could not get the controller to show when passing the ID of an empty <code>LinearLayout</code>. If you want to use a layout, you may need to put some kind of view inside it. I put a <code>TextView</code> inside it and viola, I had a controller. It doesn't show for long, so pay attention. There may be a parameter to set for the display timeout.</p>
 

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