Hello everyone,
I'm developing a web app that basically plays a few wav files (Before asking, nope, mp3 is not an option so great code such as soundmanager by Scott Schiller is unavailable for use).
I'd like to have something that plays multiple wav files in sequence. The wav files will be embedded on a webpage. The way this works is, the user clicks the "Next" or "Previous" link, and Javascript will change the wav file current playing, and display its information (filename, duration, etc.) on the page.
I'd like the files to play sequentially without having to click these links. The way I had envisioned doing this was when JavaScript detects that the file has finished playing, it will go to the next file (updating the information on the page, of course)
That's all fine and dandy, but I cannot for the life of me figure out if JavaScript has any way to detect when this file has finished playing! I've searched and searched, but have come up with nothing that I could use.
If it helps, the way I am embedding the wav files in a way so that they are compliant with Strict XHTML. The code looks something like this:
CODE
<div id="call_wav">
<object type="audio/x-wav" data="wav_embed.php?filename=<?php echo $filenames[0]; ?>" width="200" height="20">
<param name="src" value="wav_embed.php?filename=<?php echo $filenames[0]; ?>" />
<param name="autoplay" value="false" />
<param name="autoStart" value="0" />
Recording file
</object>
</div>
wav_embed.php needs to be there because the wave files are NOT stored in a web-accessible folder, but in another folder on the server. I have been security minded and have been sure to sanitize the filename read and to prevent upward directory traversal with .. or anything silly like that (although any pointers you have on how to do that would help me to ensure that I have not missed any holes!)
JavaScript will rewrite that div to change the src and data values when the "Next" and "Previous" links are clicked.
I know of one alternative - because I know the duration of each file, I can set a timer that starts when the file has loaded, and when triggered will advance the file. However, I am reluctant to use this method, because I believe it may be unreliable if I cannot accurately tell when the file has finished loading.
Instead, I would like to be able to detect when the wav file has finished loading. Is there any way to do so? Any pointers would be greatly appreciated. Thank you.
This post has been edited by guahguahmonster: 7 Aug, 2008 - 09:15 PM