Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Sorry to burst your bubble, but...</p> <p>1) You have a misunderstanding about what a "track" denotes. A track can have multiple channels (e.g., a stereo track has left and right channels). As I understand it, stereo is the extent of the Android AudioTrack implementation at present. I haven't yet checked if the OpenSL implementation is more extensive than the Java API.</p> <p>2) Only 1 audio track can be selected at a time, so you wouldn't be able to have background and narration simultaneously in the way you were thinking.</p> <p>3) Audio tracks can only be selected in the prepared state (i.e., not after playback has started). The <a href="http://developer.android.com/reference/android/media/MediaPlayer.html#selectTrack%28int%29" rel="nofollow">documentation</a> mentions this limitation is not ideal, so it will probably change in the future. If not for this problem, your goal could be accomplished with two audio tracks encoded in the stream, one with both background &amp; narration, the other just background.</p> <p>You will probably find it difficult to synchronize two <code>MediaPlayer</code>s, but I haven't tried. Maybe this approach would be acceptable for your situation, although be forewarned the <code>seekTo</code> method isn't accurate. It depends on the encoding of the files.</p> <p>Something I would try if I were you is to have two complete encoded videos, one with narration, the other without. Use two <code>MediaPlayer</code>s and keep them both prepared. When you want to switch use <code>seekTo</code> to put the correct one at (or near) the desired location. That way you don't have to worry about synchronization. If the video is large, this method could use significantly more resources, though.</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