niftyPlayer
Demo
This is what niftyPlayer looks like:
...and it is controllable with JavaScript:
play toggle (or play | pause ) stopload file 1 | load file 2 | load file 2 and play it
register onPlay event (then click the play button to see the result)
get current file state
Upsides
- Small (~4kb)
- Free, open-source
- No Flash knowledge required: file URL is specified in HTML
- JavaScript-ready! You may even bypass the Flash interface altogether!
- Autostart capability
- Draggable/Clickable seek bar
- Simple operation with Play/Pause and Stop buttons
- Buffering with progress bar
- Buffering is stoppable! (through Stop button)
- Volume control
- Very verbal
- Retries upon encountering errors
Downsides
- No playlist capability (but can be done in JavaScript!)
- No photo-slideshow or video capability
- Sound must be MP3 (flash limitation)
- I'm sure there's more, but I can't really think of any other. But, hey, did I mention it's open-source? You can always change the code :)
Usage
Copy and paste the code below into your HTML file, then replace all values in red accordingly.
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="165" height="38" id="niftyPlayer1" align=""> <param name=movie value="niftyplayer.swf?file=betty.mp3&as=1"> <param name=quality value=high> <param name=bgcolor value=#FFFFFF> <embed src="niftyplayer.swf?file=betty.mp3&as=1" quality=high bgcolor=#FFFFFF width="165" height="38" name="niftyPlayer1" align="" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer"> </embed> </object>
If you'd like to use the JS extension, include the code below in your HTML file (it usually goes inside the head
section). You may set the height and width of the Flash (in blue, above) to 0 to make it disappear -- or use CSS, alternatively.
<script type="text/javascript" language="javascript" src="niftyplayer.js"></script>
Also, you may want to check out the FlashMP3alizer script too.
Reference
Parameter | Explanation |
---|---|
file=betty.mp3
|
substitute betty.mp3 for the file you want to play |
as=1
|
this specifies whether you want the file to auto-start playing. you may ommit as if you don't want it to auto-start.
|
Download
Note: Please do not hotlink to NiftyPlayer. I do have to pay for bandwidth, you know? :)
(This program is licensed under the MIT License, which, to put it in non-legal terms, allows you to share, use and modify it. Even for commercial purposes. Check out the Wikipedia article on this license for more.)
Acknowldgements
Part of the JavaScript code was pretty much copied from this website http://www.moock.org/webdesign/flash/fscommand/. They offer a great explanation of Flash/Javascript interoperation.
The info they give may be a little outdated by now, though...
News
Version 1.7 is out: Bug-fix release. Introduces the getState()
JavaScript function.
Now with "News" section!