Note that there are some explanatory texts on larger screens.

plurals
  1. POPlay media file and append it in the same time
    primarykey
    data
    text
    <p>I am developing media player, which should be able to play audio from Internet. As I've noticed, standard <code>MediaPlayer</code> is quite unstable when playing remote content: It is often falls or stops playback with no reason. On the other side, I want to implement media caching. But I haven't found any way to get buffered content from <code>MediaPlayer</code> to save it somewhere on device.</p> <p>So, I'd like to implement buffering for myself and make <code>MediaPlayer</code> play only local media. The first way I see is to download enough piece of media to a file, start playing this file via <code>MediaPlayer</code> and continue downloading the rest of media (with pausing when not enough media downloaded and processing other events like that). </p> <p>The question is: it is possible to play file and append it in the same time? Now I only have <code>IllegalStateExceptions</code> when calling <code>MediaPlayer</code>'s <code>setDataSource</code></p> <p><strong>UPD</strong></p> <p><code>IllegalStateException</code> was caused by invalid logic. MediaPlayer is playing now. </p> <p>But the other issue appeared.</p> <p>So, first 5% of track is downloaded, MediaPlayer start playing, play these 5% and then stops. Is it a way to keep playing?</p> <p>Starting playback is trivial:</p> <pre><code>private void startPlayback(final File file) { try { FileInputStream fs = new FileInputStream(file); mPlayer.setDataSource(fs.getFD()); mPlayer.prepare(); mPlayer.start(); } catch (IOException e) { Log.e(e); } } </code></pre> <p>May be there is other stream type useful for this case?</p>
    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