I want to produce a simple, static HTML file, that has one or more embedded MP3 files in it. The idea is to have a simple mean of listening to specific parts of an mp3 file.
On a single click on a visual element, the sound should start to play; However, not from the beginning of the file, but from a specified starting point in th开发者_如何学编程at file (and play to the end of the file). This should work all locally from the client's local filesystem, the HTML file and the MP3 files do not reside on a webserver.
So, how to play the MP3 audio from a specific starting point? The solution I am looking for should be as simple as possible, while working on most browsers, including IE, Firefox and Safari.
Note: I know the <embed>
tag as described here, but this seems not to work with my target browsers. Also I have read about jPlayer and other Java-Script-based players, but since I have never coded some JavaScript, I would prefer a HTML-only solution, if possible.
Update: By now this has become a live tool, located at http://quir.li/player.html. I ended up using the excellent mediaplayer.js by John Dyer
I'm sorry but I don't think it is possible to skip to a specific position in a track without any form of client-side scripting. It is possible to just play a track without client-side scripting using a link with its target pointing to an iframe on your page.
Eg.
<a href="audioembedded.html" target="myplayer">Play audio</a>
<iframe src="nothingplayingnow.html" name="myplayer"></iframe>
If you'd like to embed the audio file itself into the html document, I think the closest you'd get would be to use the data URI scheme. All the pros and cons are explained nicely in that article.
But all of this is of course possible if you use a bit of client-side scripting. This flash MP3-player lets you skip to certain positions via a javascript interface. The site also has a generator which lets you make your own player interface very easily.
Sorry, but I think you'll have to use at least some javascript to achieve what you're attempting.
精彩评论