Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid VideoView Playback Controls Show "Play" Initially Instead of "Pause" Even Though File is Already Playing
    primarykey
    data
    text
    <p>Good afternoon/morning! Hoping someone could help me out with a small problem I'm having. I'm playing a remote .mp3 file using a <code>VideoView</code> and a custom <code>MediaController</code>.</p> <p>My MediaController looks like this:</p> <pre><code>public class MyMediaController extends MediaController { public MyMediaController(Context context) { super(context); } // Do nothing on the overridden hide method so the playback controls will never go away. @Override public void hide() { } // Override the dispatchKeyEvent function to capture the back KeyEvent and tell the activity to finish. @Override public boolean dispatchKeyEvent(KeyEvent event) { if (event.getKeyCode() == KeyEvent.KEYCODE_BACK) { ((Activity) getContext()).finish(); } return super.dispatchKeyEvent(event); } </code></pre> <p>}</p> <p>And my code to attach it to my <code>VideoView</code> looks like this:</p> <pre><code> VideoView videoView = (VideoView) findViewById(R.id.VideoView); // Use our own media controller, which inherits from the standard one. Do this to keep // playback controls from disappearing. mediaController = new MyMediaController(this); mediaController.setAnchorView(videoView); Uri video = Uri.parse(URL); videoView.setMediaController(mediaController); videoView.setVideoURI(video); // Set a handler that will show the playback controls as soon as audio starts. videoView.setOnPreparedListener(new OnPreparedListener() { @Override public void onPrepared(MediaPlayer arg0) { mediaController.show(); } }); videoView.start(); </code></pre> <p>The problem I'm having is that when the .mp3 file starts playing, the control bar at the bottom has the "Play" button showing (i.e. triangle) instead of the "Pause" button (two parallel bars) even though the audio is already playing. Anyone know how to fix this?</p> <p>EDIT 1:</p> <p>I'd also be interested in any other solutions for playing a remote .mp3. The only requirements I have are that the user can pause/play the audio and also see what the name of the audio file (title) is.</p> <p>Thank you!</p>
    singulars
    1. This table or related slice is empty.
    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.
    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