Playing audio from octet-stream

2,446 views
Skip to first unread message

Juan Manuel Alvarez

unread,
May 25, 2010, 7:45:33 PM5/25/10
to jPlayer: the CSS styleable jQuery audio player plugin
Hi! I am new to jPlayer and I would like to ask a question.

I am trying to play an OGG from an octet-stream like follows:

My player.php header sets the audio file like this:
$("#jquery_jplayer").jPlayer({
ready: function () {
this.element.jPlayer("setFile","<?php echo $audio_link; ?>","<?php
echo $audio_link; ?>").jPlayer("play");
},
volume: 50,
oggSupport: true
})

The variable $audio_link has the value audio_link.php that looks like
this:

header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment;
filename='.basename($target_filename));
header('Content-Transfer-Encoding: binary');
header('Expires: 0');
header('Cache-Control: no-cache, must-revalidate, post-check=0, pre-
check=0');
header('Pragma: public');
header('Content-Length: '.GetRemoteFileSize($audio_link) );
header('Accept-Ranges: bytes');

ob_clean();
flush();
@readfile($download_link);

GetRemoteFileSize returns the correct size and all the variables have
correct values, but the audio does not play. I am using the same
approach with images and video and they work OK.

Can anyone please point me in the right direction?
Thanks in advance and keep the excellent work!

Juan M.

Wurlitzer

unread,
May 26, 2010, 10:24:16 AM5/26/10
to jPlayer: the CSS styleable jQuery audio player plugin
I'm sorry I cannot help you on this subject, but I have a question
about it.
Would playing audio from an octet stream, be a way of effectively
hiding the location of the audio files on the server, from the user?

Mark P

unread,
May 26, 2010, 4:38:08 PM5/26/10
to jPlayer: the CSS styleable jQuery audio player plugin
Hello Juan,

The browsers that play OGG format are fussy about the mime type. It
has to be application/ogg or audio/ogg for it to work.

The other thing, it looks like you give the same URL for the mp3 and
ogg files. You give no details of which browsers do or do not work...
When you set oggSupport to true, the 2nd file parameter must point to
an OGG format otherwise jPlayer will not work.

@Wurlitzer: Search this group and you should find info on hiding the
mp3 urls. The best approach seems to be to restrict the referrer URL
to disable direct access. You can parse the mp3 file through a PHP
file, but it would take up server resources and you have to make it
'accept-ranges' correctly.

Best regards,
Mark P.

Juan Manuel Alvarez

unread,
May 28, 2010, 4:10:01 PM5/28/10
to jPlayer: the CSS styleable jQuery audio player plugin
Hi Mark! Thanks for the quick reply.

I only need the player to play OGG files an I am testing it with
Opera.
I have also tried using application/ogg and audio/ogg as mime types
with no success.

Is there another place I can take a look at?
Any other help will be much appreciated.

Thanks in advance!
Juan M.

Juan Manuel Alvarez

unread,
May 30, 2010, 1:44:17 PM5/30/10
to jPlayer: the CSS styleable jQuery audio player plugin
I finally worked out what was wrong, and it had nothing to do with
jPlayer.

The problem was that the audio file I was testing with had spaces in
its name, so it had to be encoded for passing it as an URL.
I took the encoding function from here and it worked great:
http://www.php.net/manual/en/function.rawurlencode.php#48792.

Thanks for all the help!
Juan M.
Reply all
Reply to author
Forward
0 new messages