Forums / Setup & design / mp3 files on webpage

mp3 files on webpage

Author Message

Piotr Switkowski

Wednesday 02 June 2004 2:52:06 am

I have a template designed on FILE class including audio mp3 files. To access the binary file I have a link with HREF starting with "/content/download/...". When opening this link, browser display dialog asking whether download or open the file. I would like browser to immediately play the .mp3 file instead of downloading. Could anybody help ?

My diagnosis is that browser opens index.php (so file of mime-type application) rather then .mp3, but I did not find ather way of constructing URL of binary file (without index.php)

On the other hand, should'nt download send proper header, so browser will know it is downloading .mp3 file, not application?

Ulrich L.

Wednesday 16 March 2005 4:45:06 am

I've got the same problem, so I'd like to revitalize this thread...
I made the same experience: Using the file datatype results always in a download request window of the browser, no immediate streaming.

The following workaraund is working, but not very comfortable: Uploading the mp3-Files manually and creating a link in ezpublish.

Is there any other known way to deal with mp3? (I use mp3 in order to provide free examples of audio.)

Jack Rackham

Wednesday 16 March 2005 5:40:48 am

Well .mp3 handling depends on your browser.
In IE 6 it opens this download/open dialog, but in Firefox 1.x it automatically opens the file.
Try it out: http://www.google.com/search?hl=en&q=%22index+of%22+mp3
Instead you can use a streaming format like .mov .asf .raw.........

Ulrich L.

Wednesday 16 March 2005 5:50:47 am

Sorry, but my IE6 doesn't open dialog in case of mp3 streams (I just tested it with your link ;-) ). So I think the problem remains the same.

Gabriel Ambuehl

Wednesday 16 March 2005 6:27:44 am

Did you look into the template of the File content class? Maybe you can change the redirect to a direct link?

Visit http://triligon.org

Ulrich L.

Wednesday 16 March 2005 9:42:50 am

I'm not sure wether I fully understand the 'file' templates.
Now I created a class for my audio examples which includes an attribute "stream_file" which is a binary file. The following piece of code results in immediate mp3 playback:

<a href={$node.object.data_map.stream_file.content.filepath|ezroot}>{$node.name|wash()}</a>

However, the URL is not a nice one, it's like this:
<ezroot>/var/shop/storage/original/audio/439ae3b40d3cf881733d0a79ee506770.mp3

Any suggestions to further improve this solution are welcome, of course...

Ɓukasz Serwatka

Wednesday 16 March 2005 10:43:18 am

Hi Uli,

Try this code to display link to download your file.

<a href={concat( 'content/download/',
$node.object.data_map.stream_file.contentobject_id, '/',
$node.object.data_map.stream_file.id, '/file/',
$node.object.data_map.stream_file.content.original_filename|urlencode )|ezurl}>
{$node.object.data_map.stream_file.content.original_filename|wash( xhtml )}
</a>

Personal website -> http://serwatka.net
Blog (about eZ Publish) -> http://serwatka.net/blog

Ulrich L.

Wednesday 16 March 2005 11:40:38 am

This suggestion is very interesting (so much to learn here!), however, the result is again a download window of the browser. That means at the moment I still prefer "my" solution...