I'm working on a book which should allow the playing of MP3s at selected points. I've found a good solution for the general case (i.e. the entire file): Audio examples in phonetics project, however, I also want to play portions of the files as well (e.g. words or phrases within sentences).
One solution is to use audio software to split the file into the necessary sections, but this of course produces a lot of unnecessary duplication.
The documentation for media9 mentions seek, which is half a solution (though I confess it isn't clear to me how to make this work). Hunting through JavaScript documentation has revealed this code, which suggests it is possible:
var player = app.media.openPlayer({
rendition: this.media.getRendition( "myAudio" ),
doc: this,
settings: {
startAt: 3,
endAt: 8
}
});
The MWE given in the link above is as follows:
\documentclass{article}
\usepackage{media9,graphicx}
\begin{document}
Sound sample: \includemedia[
addresource=sound_sample.mp3,
transparent,
flashvars={
source=sound_sample.mp3
&autoPlay=true
},
]{\includegraphics[height=1.44ex]{speaker.png}}{APlayer.swf}
\end{document}
I'd be grateful for any suggestions on how to proceed.
Best Answer
Version
2014/06/25
ofmedia9
has updated playersAPlayer.swf
andVPlayer.swf
.The
play
andpause
methods of their programming interface now accept optional arguments which are time offsets, measured in seconds, into the media file. Thus, a properly configured\mediabutton
lets the embedded player play a portion of the media file.A generic sound example with two buttons which is similarly useable for video:
In the particular case of a phonetics project, the same sound file may need to be playable on different pages of the document. Here we need to embed the audio player at least once per sound file and per page on which the player is referenced by media buttons. For this to do automatically, the code example below defines the command
Note, that a particular sound file and the player SWF are only once embedded physically into the document. Thus, repeated
\includemedia
for the same sound file on different pages do not add much to the PDF file size.Complete example using a sound URL: