Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>One way is to concatenate them into a single audio file, then create a MediaPlayer for it and set an OnSeekCompleteListener. Seek to each segment in tern in whichever order you like and then play them in onSeekComplete(). It's timing not exact and MediaPlayer is touchy to use so it may not be the best choice for you but it's good enough for my purposes.</p> <p>Here's my code:</p> <pre><code>private MediaPlayer MP = new MediaPlayer(); @Override public void onCreate(Bundle savedInstanceState) { //... FileDescriptor fd = getResources().openRawResourceFd(R.raw.pronounciations).getFileDescriptor(); try { setVolumeControlStream(AudioManager.STREAM_MUSIC); // Lets the user control the volume. MP.setDataSource(fd); MP.setLooping(false); MP.prepare(); MP.start(); // HACK! Some playing seems required before seeking will work. Thread.sleep(60); // Really need something like MediaPlayer.bufferFully(). MP.pause(); MP.setOnErrorListener(new OnErrorListener() { public boolean onError(MediaPlayer mp, int what, int extra) { return false; } }); MP.setOnSeekCompleteListener(new OnSeekCompleteListener() { public void onSeekComplete(MediaPlayer mp) { // The clip is queued up and read to play. // I needed to do this in a background thread for UI purposes. // You may not need to. new Thread() { @Override public void run() { MP.start(); try { Thread.sleep(soundRanges[curWordID][1]); } catch(InterruptedException e) {} MP.pause(); } }.start(); } }); } catch(Throwable t) {} } private void playCurrentWord() { if(soundRanges != null &amp;&amp; !MP.isPlaying() &amp;&amp; !silentMode) { try { MP.seekTo(soundRanges[curWordID][0]); } catch(Throwable t) {} } } </code></pre> <p>You would likely need to concatenate your clips using an external sound editing tool. I used Audacity to find and edit the clip beginnings and lengths that I saved in a file.</p> <p>soundRanges[curWordID][0] is the offset in the sound file of the beginning of a clip and soundRanges[curWordID][1] is its length.</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.
    1. This table or related slice is empty.
    1. VO
      singulars
      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