This blog entry was posted by peter on June 27, 2007.
It is tagged with audio, Django, Flash, mp3, and Python.
So far there are 9 comments. Feel free to add one.
The previous entry chronologically is instantplayer beta 1 released.
A Django application for integrating a Flash based mp3 audioplayer into templates using a custom template tag. It uses the flashplayer from 1pixelout and can be easily customized by template parameters.
The audioplayer app is only available as a tarball. It contains the Django application and the flashplayer from 1pixelout. Also note the Changelog
The audioplayer app can also be checked out from the SVN at GoogleCode.
To install the audioplayer app, follow these steps:
That’s it. The audioplayer does not use any models or views, only a custom template tag named audioplayer.
The audioplayer can be used in any template like this:
1 2 3 4 | {% load audioplayer %}
# …
{% audioplayer file=file_url %}
# …
|
First load the audioplayer template tag library, then instantiate the player as often as you like, using different files and/or player configurations.
Here’s a live example:
hello,
really cool app. Yesterday I tried it, but I found 2 errors.
1) your documentation says
>> By default the audioplayer tag uses the player.swf found at
>> {{ MEDIA_URL }}/audioplayer/player.swf.
But in your code is:
player_url = “%s/player.swf” % (settings.MEDIA_URL)
2) your documentation says
>> Please be aware that the original values for the autostart and loop has been
>> pythonified: Instead of using yes and no the audioplayer tag uses False and True.
But autostart/loops does only works, if I pass yes/no to the autostart/loop parameter, because urlencode writes True to the parameter string, if I pass True to autostart/loop parameter
in your code:
player_flash_params = urlencode(self.params)
@Bernd: Thanks for reporting those bugs. I have uploaded a new version which fixes the issues. The new version also uses a template for the inserted code.
You can check the Changelog at the end of the blog entry for details.
Hello,
really great, fast response and a new version.
But now there is another input from me. I use Firefox with the “HTML Validator”-Extension. It shows an error an the page with the audioplayer.
The line with the error is:
<param name=”FlashVars” value=”height=30&bg=0xF7F7F7&slider=0x344CF7&track=0x777777&righticon…… />
The clean-up-version of the extension look like this:
<param name=”FlashVars” value=
“height=30&bg=0xF7F7F7&slider=0x344CF7&track=0x777777&…
It would be great to correct the char “&” and write the HTML-Entity instead the original character.
Regards,
Bernd
Hi Bernd,
i fixed the entity replacement and uploaded a bugfix release. I tested it with the W3C validator and the player code validates now. Again the Changelog has some details.
Hope this works for you.
Hello Peter,
with the latest django-trunk, your last change doesn't work. I think it's because of the new autoescape-feature.
I had to change the line:
player_flash_params = urlencode(self.params).replace('&', '&')
to
player_flash_params = urlencode(self.params)
I have created a new version which should fix the autoescape issues. Please see the changelog and the updated documentation for more info.
The audioplayer was also moved to GoogleCode. Read about that here:
http://pyjax.net/blog/1/2008/03/02/mo…
Excellent! This is exactly what I needed. Is there any way to have multiple songs play? I know that the player.swf supports multiple mp3s. How can I input them? Thanks.
If you'd like you can reply to http://kbpeterson(at)gmail.com
Fantastic work! Before I ran into this code I was actually outputting the code to the audioplayer.swf by hand in the HTML template… but this is so much nicer! :-)
However, there's a think I can't get to work. I'm trying to play a file that has a comma (“,”) as part of the filename, which is valid for Apache and my Kubuntu laptop, where this code lives.
Could you help me with this, please? Is that something related to the autoescape feature, maybe?
Thanks again, and have a nice day!
peter said on August 26, 2007
Test comment. No real content. Really. Nothing.