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...

eZ debug

Timing: Jan 18 2025 21:16:37
Script start
Timing: Jan 18 2025 21:16:37
Module start 'content'
Timing: Jan 18 2025 21:16:38
Module end 'content'
Timing: Jan 18 2025 21:16:39
Script end

Main resources:

Total runtime1.5863 sec
Peak memory usage4,096.0000 KB
Database Queries215

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0060 587.7031180.8438
Module start 'content' 0.00601.3320 768.5469706.8281
Module end 'content' 1.33800.2482 1,475.3750340.4453
Script end 1.5862  1,815.8203 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00400.2500210.0002
Check MTime0.00150.0967210.0001
Mysql Total
Database connection0.00060.035910.0006
Mysqli_queries1.502794.73282150.0070
Looping result0.00280.17442130.0000
Template Total1.557598.220.7788
Template load0.00210.131720.0010
Template processing1.555498.054420.7777
Template load and register function0.00020.013810.0002
states
state_id_array0.00080.049610.0008
state_identifier_array0.00120.077920.0006
Override
Cache load0.00180.1135350.0001
Sytem overhead
Fetch class attribute can translate value0.00130.080760.0002
Fetch class attribute name0.00120.0758100.0001
XML
Image XML parsing0.00170.106960.0003
class_abstraction
Instantiating content class attribute0.00000.0009100.0000
General
dbfile0.00220.1385350.0001
String conversion0.00000.000330.0000
Note: percentages do not add up to 100% because some accumulators overlap

CSS/JS files loaded with "ezjscPacker" during request:

CacheTypePacklevelSourceFiles
CSS0extension/community/design/community/stylesheets/ext/jquery.autocomplete.css
extension/community_design/design/suncana/stylesheets/scrollbars.css
extension/community_design/design/suncana/stylesheets/tabs.css
extension/community_design/design/suncana/stylesheets/roadmap.css
extension/community_design/design/suncana/stylesheets/content.css
extension/community_design/design/suncana/stylesheets/star-rating.css
extension/community_design/design/suncana/stylesheets/syntax_and_custom_tags.css
extension/community_design/design/suncana/stylesheets/buttons.css
extension/community_design/design/suncana/stylesheets/tweetbox.css
extension/community_design/design/suncana/stylesheets/jquery.fancybox-1.3.4.css
extension/bcsmoothgallery/design/standard/stylesheets/magnific-popup.css
extension/sevenx/design/simple/stylesheets/star_rating.css
extension/sevenx/design/simple/stylesheets/libs/fontawesome/css/all.min.css
extension/sevenx/design/simple/stylesheets/main.v02.css
extension/sevenx/design/simple/stylesheets/main.v02.res.css
JS0extension/ezjscore/design/standard/lib/yui/3.17.2/build/yui/yui-min.js
extension/ezjscore/design/standard/javascript/jquery-3.7.0.min.js
extension/community_design/design/suncana/javascript/jquery.ui.core.min.js
extension/community_design/design/suncana/javascript/jquery.ui.widget.min.js
extension/community_design/design/suncana/javascript/jquery.easing.1.3.js
extension/community_design/design/suncana/javascript/jquery.ui.tabs.js
extension/community_design/design/suncana/javascript/jquery.hoverIntent.min.js
extension/community_design/design/suncana/javascript/jquery.popmenu.js
extension/community_design/design/suncana/javascript/jScrollPane.js
extension/community_design/design/suncana/javascript/jquery.mousewheel.js
extension/community_design/design/suncana/javascript/jquery.cycle.all.js
extension/sevenx/design/simple/javascript/jquery.scrollTo.js
extension/community_design/design/suncana/javascript/jquery.cookie.js
extension/community_design/design/suncana/javascript/ezstarrating_jquery.js
extension/community_design/design/suncana/javascript/jquery.initboxes.js
extension/community_design/design/suncana/javascript/app.js
extension/community_design/design/suncana/javascript/twitterwidget.js
extension/community_design/design/suncana/javascript/community.js
extension/community_design/design/suncana/javascript/roadmap.js
extension/community_design/design/suncana/javascript/ez.js
extension/community_design/design/suncana/javascript/ezshareevents.js
extension/sevenx/design/simple/javascript/main.js

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1node/view/full.tplfull/forum_topic.tplextension/sevenx/design/simple/override/templates/full/forum_topic.tplEdit templateOverride template
8content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
9content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
4content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
2content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
2content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/pagelayout.tplEdit templateOverride template
 Number of times templates used: 27
 Number of unique templates used: 7

Time used to render debug report: 0.0002 secs