[jPlayer] Trouble with seek and stop button

12035 views
Skip to first unread message

Joe Lencioni

unread,
May 10, 2010, 3:47:57 PM5/10/10
to jPlayer: the CSS styleable jQuery audio player plugin
I am working on a project that uses jPlayer (currently version 1.1.1)
to play .ogg files in the browser. Access to these files is restricted
in a number of ways so I need to send the requests through a PHP
script and things are mostly working.

However, I am having issues with seeking within a track and the stop
button. Play, pause, next track, previous track, and volume controls
all work flawlessly, but clicking on the progress bar to jump around
the track and clicking on the stop button do nothing. I have been
trying to figure out what is wrong, but I haven't come up with much
yet.

As far as I can tell, this seems to only be happening when I stream
the files through my PHP script. In other words, if I take the
identical file and reference it directly on my server, everything
works as expected. But, when I serve it through my PHP script, the
file plays but the seek and stop features are broken.

These are the headers that are being sent with the two different
files.

Direct request:

HTTP/1.1 200 OK
Date: Mon, 10 May 2010 19:37:23 GMT
Server: Apache/2.2.3 (Red Hat)
Last-Modified: Wed, 14 Apr 2010 21:37:26 GMT
Accept-Ranges: bytes
Content-Length: 2108976
Cache-Control: max-age=600
Expires: Mon, 10 May 2010 19:47:23 GMT
Content-Type: application/ogg


Served through PHP script:

HTTP/1.1 200 OK
Date: Mon, 10 May 2010 19:37:21 GMT
Server: Apache/2.2.3 (Red Hat)
X-Powered-By: PHP/5.3.2
Last-Modified: Wed, 14 Apr 2010 16:37:26 -0500
Accept-Ranges: bytes
Content-Length: 2108976
Cache-Control: max-age=600
Expires: Mon, 10 May 2010 19:47:21 GMT
Content-Type: application/ogg


Versions:
jQuery: 1.4.2
jPlayer: 1.1.1
Google Chrome: 5.0.375.29 beta
Windows: 7

If anybody can help me out, I would greatly appreciate it.
Thanks!

--
You received this message because you are subscribed to the Google Groups "jPlayer: the CSS styleable jQuery audio player plugin" group.
To post to this group, send email to jpl...@googlegroups.com.
To unsubscribe from this group, send email to jplayer+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/jplayer?hl=en.

Eamon Nerbonne

unread,
May 11, 2010, 4:41:55 AM5/11/10
to jpl...@googlegroups.com
Does your php script actually support range requests?

i.e., does it parse the Range headers and send the correct range of bytes with a status 206 - at a minimum; and preferably also deal with ETags and modification headers?  That's generally non-trivial in script, and would cause the kind of issues you're seeing.  You do announce the support for range request via the Accept-Ranges:bytes header, so, you might get away with just dropping that header.

Try attaching something like Http Fiddler and comparing the behaviour of the apache-served requests with your PHP requests.

Good Luck,
Eamon Nerbonne
--ea...@nerbonne.org - Tel#:+31-6-15142163

Joe Lencioni

unread,
May 11, 2010, 11:06:35 AM5/11/10
to jPlayer: the CSS styleable jQuery audio player plugin
Thanks for the response. Good suggestions--I had actually tried adding
support for range requests using this function on the PHP site:
http://www.php.net/manual/en/function.readfile.php#86244 This gives me
these headers:

HTTP/1.1 200 OK
Date: Tue, 11 May 2010 15:01:54 GMT
Server: Apache/2.2.3 (Red Hat)
X-Powered-By: PHP/5.3.2
Cache-Control: public, must-revalidate, max-age=0, max-age=600
Pragma: no-cache
Accept-Ranges: bytes
Content-Length: 2108976
Content-Range: bytes 0-2108976/2108976
Content-Disposition: inline; filename=02.ogg
Content-Transfer-Encoding: binary
Last-Modified: Wed, 14 Apr 2010 16:37:26 -0500
Connection: close
Expires: Tue, 11 May 2010 15:11:54 GMT
Content-Type: application/ogg

Unfortunately, I am experiencing the same issues with this technique.
I have also tried messing around with some of the headers that it
sends, including your suggestion of dropping the Accept-Ranges: bytes
header, but no combination seems to do the trick.

Any other thoughts?
> > jplayer+u...@googlegroups.com<jplayer%2Bunsu...@googlegroups.com >
> > .
> > For more options, visit this group at
> >http://groups.google.com/group/jplayer?hl=en.
>
> --
> You received this message because you are subscribed to the Google Groups "jPlayer: the CSS styleable jQuery audio player plugin" group.
> To post to this group, send email to jpl...@googlegroups.com.
> To unsubscribe from this group, send email to jplayer+u...@googlegroups.com.
> For more options, visit this group athttp://groups.google.com/group/jplayer?hl=en.

Joe Lencioni

unread,
May 11, 2010, 2:28:13 PM5/11/10
to jPlayer: the CSS styleable jQuery audio player plugin
I discovered some problems with the function that I linked to that I
think are making this not work. I will fix them and keep you posted.

On May 11, 10:06 am, Joe Lencioni <joe.lenci...@gmail.com> wrote:
> Thanks for the response. Good suggestions--I had actually tried adding
> support for range requests using this function on the PHP site:http://www.php.net/manual/en/function.readfile.php#86244This gives me

Joe Lencioni

unread,
May 11, 2010, 3:59:42 PM5/11/10
to jPlayer: the CSS styleable jQuery audio player plugin
I believe I have it working now. Thanks for your help. The HTTP
Fiddler tool you suggested was quite helpful in tracking down and
solving the issue.

The problem was the PHP function that handles the range requests had
some bugs in it. I fixed them and posted a comment over there. For
reference, here's the fixed version of the function I am using:

<?php
function smartReadFile($location, $filename, $mimeType = 'application/
octet-stream')
{
if (!file_exists($location))
{
header ("HTTP/1.1 404 Not Found");
return;
}

$size = filesize($location);
$time = date('r', filemtime($location));

$fm = @fopen($location, 'rb');
if (!$fm)
{
header ("HTTP/1.1 505 Internal server error");
return;
}

$begin = 0;
$end = $size - 1;

if (isset($_SERVER['HTTP_RANGE']))
{
if (preg_match('/bytes=\h*(\d+)-(\d*)[\D.*]?/i',
$_SERVER['HTTP_RANGE'], $matches))
{
$begin = intval($matches[1]);
if (!empty($matches[2]))
$end = intval($matches[2]);
}
}

if ($begin > 0 || $end < $size)
header('HTTP/1.1 206 Partial Content');
else
header('HTTP/1.1 200 OK');

header("Content-Type: $mimeType");
header('Cache-Control: public, must-revalidate, max-age=0');
header('Pragma: no-cache');
header('Accept-Ranges: bytes');
header('Content-Length:' . ($end - $begin) + 1);
header("Content-Range: bytes $begin-$end/$size");
header("Content-Disposition: inline; filename=$filename");
header("Content-Transfer-Encoding: binary\n");
header("Last-Modified: $time");

$cur = $begin;
fseek($fm, $begin, 0);

while(!feof($fm) && $cur < $end && (connection_status() == 0))
{
print fread($fm, min(1024 * 16, ($end + 1) - $cur));
$cur += 1024 * 16;
}
}
?>

On May 11, 1:28 pm, Joe Lencioni <joe.lenci...@gmail.com> wrote:
> I discovered some problems with the function that I linked to that I
> think are making this not work. I will fix them and keep you posted.
>
> On May 11, 10:06 am, Joe Lencioni <joe.lenci...@gmail.com> wrote:
>
>
>
>
>
> > Thanks for the response. Good suggestions--I had actually tried adding
> > support for range requests using this function on the PHP site:http://www.php.net/manual/en/function.readfile.php#86244Thisgives me

Eamon Nerbonne

unread,
May 12, 2010, 3:11:06 AM5/12/10
to jpl...@googlegroups.com
Congratulations - it's not easy fixing bugs in external functions like that :-).

Joe Lencioni

unread,
Apr 27, 2011, 10:19:01 AM4/27/11
to jpl...@googlegroups.com
I discovered a problem with this code in Chrome. Apparently, sending the HTTP 200 header prevents Chrome from displaying the progress bar and allowing seek. So, change this:

if ($begin > 0 || $end < $size) 
header('HTTP/1.1 206 Partial Content'); 
else 
header('HTTP/1.1 200 OK'); 


To this:

header('HTTP/1.1 206 Partial Content');

And it works again.

Here's the full function:

/**
* Reads the requested portion of a file and sends its contents to the client with the appropriate headers.
* This HTTP_RANGE compatible read file function is necessary for allowing streaming media to be skipped around in.
* @param string $location
* @param string $filename
* @param string $mimeType
* @return void
*/
function smartReadFile($location, $filename, $mimeType = 'application/octet-stream')
{
if (!file_exists($location))
{
header ("HTTP/1.1 404 Not Found");
return;
}
$size = filesize($location);
$time = date('r', filemtime($location));
$fm = @fopen($location, 'rb');
if (!$fm)
{
header ("HTTP/1.1 505 Internal server error");
return;
}
$begin = 0;
$end = $size - 1;
if (isset($_SERVER['HTTP_RANGE']))
{
if (preg_match('/bytes=\h*(\d+)-(\d*)[\D.*]?/i', $_SERVER['HTTP_RANGE'], $matches))
{
$begin = intval($matches[1]);
if (!empty($matches[2]))
{
$end = intval($matches[2]);
}
}
}

header('HTTP/1.1 206 Partial Content');
header("Content-Type: $mimeType"); 
header('Cache-Control: public, must-revalidate, max-age=0');
header('Pragma: no-cache');  
header('Accept-Ranges: bytes');
header('Content-Length:' . (($end - $begin) + 1));
header("Content-Range: bytes $begin-$end/$size");
header("Content-Disposition: inline; filename=$filename");
header("Content-Transfer-Encoding: binary");
header("Last-Modified: $time");
$cur = $begin;
fseek($fm, $begin, 0);
while(!feof($fm) && $cur <= $end && (connection_status() == 0))
{
print fread($fm, min(1024 * 16, ($end - $cur) + 1));

Mark Panaghiston

unread,
Apr 27, 2011, 11:18:26 AM4/27/11
to jpl...@googlegroups.com
Nice stuff Joe. Thank you for updating us.

Chrome is so fussy about the connections. It is not jPlayer. Put an <audio controls> element in the page with the URL and you would have had the same problem.

Best regards,
Mark P.

Mark Panaghiston

unread,
Sep 20, 2011, 9:48:38 AM9/20/11
to jpl...@googlegroups.com
Hi Joe,

Does your PHP function work serving files to IE9?

I think that your response is slightly off... And all your responses are like a Range request, but if the Range is not in the request, then the whole file should be served, without the Content-Range response header.

I think this is causing IE9 to complain and it refuses to play an <audio> element with an MP3 being served through this PHP.

Best regards,
Mark P

Mark Panaghiston

unread,
Sep 20, 2011, 3:22:05 PM9/20/11
to jpl...@googlegroups.com
This new code works with IE9 and every other browser tested... Mobile and standard.

From Eoin at www.bitesizeirishgaelic.com who made the changes and was generous enough to share it with us all:

"I've simply put in two additional checks for whether it's a Range request. That determines the HTTP response sent back (200 or 206), plus if the "Content-Range" value is included."

smartReadFile.php
Message has been deleted

PAJ

unread,
Jun 19, 2012, 11:36:51 AM6/19/12
to jpl...@googlegroups.com
Could someone provide an example of how to serve an MP3 via this streaming php function?

Don Cullen

unread,
Jul 1, 2012, 2:42:10 AM7/1/12
to jpl...@googlegroups.com
Thanks for sharing the SmartRead function; I was having trouble streaming MP3's, and this effectively solved my problem. Thank you!

Don Cullen

unread,
Jul 10, 2012, 1:27:41 PM7/10/12
to jpl...@googlegroups.com
Found out the SmartRead function was failing for Safari browsers when serving MP3's. After doing research and troubleshooting, found that if I called SmartRead with a third parameter with Mpeg 3 mime types, it effectively solved the problem. Example code:

# Stream MP3
smartReadFile($track, basename($track), 'audio/mpeg, audio/x-mpeg, audio/x-mpeg-3, audio/mpeg3');

Hope this helps anyone who runs into a similar problem.
Message has been deleted

addinm...@gmail.com

unread,
Nov 16, 2012, 4:53:29 AM11/16/12
to jpl...@googlegroups.com
Can someone tell me more abt servers ?
Sent from my BlackBerry® wireless device

From: chacham15 <chacha...@gmail.com>
Date: Thu, 15 Nov 2012 18:09:50 -0800 (PST)
Subject: Re: [jPlayer] Re: Trouble with seek and stop button *

Boxbe This message is eligible for Automatic Cleanup! (chacha...@gmail.com) Add cleanup rule | More info

Mark Panaghiston

unread,
Nov 16, 2012, 1:43:17 PM11/16/12
to jpl...@googlegroups.com
@Chacham15: Who are you taking to?

What is not correct?

The post you attached in your post is older than the latest version of the smartReadFile() function code posted in the thread.

The code has the header you talk about (Accept-ranges:bytes) and it is only 1 of the many pieces of the puzzle. And the code already has that bit in it.

What was your point?

On Friday, 16 November 2012 02:09:50 UTC, chacham15 wrote:
This is actually not correct. I am implementing my own custom server so I ran into this issue as well. The reason that chrome does not allow you to seek is because there is no Accept-Ranges header, meaning that the server isnt telling the client that it can seek. The full header that should be returned by the server is: "
Accept-Ranges:
bytes"

-chacham15

h4ni

unread,
Nov 17, 2012, 4:26:50 AM11/17/12
to jpl...@googlegroups.com
Hello
i have also a seek problem with jplayer :/ (swf forced version)

Can Mark help me?

toddvalentine

unread,
Feb 28, 2013, 2:27:18 PM2/28/13
to jpl...@googlegroups.com
Has anyone been able to get this working on iOS 5.1. In particular the iPad 3?

On Saturday, November 24, 2012 6:54:27 AM UTC-6, Gabriel Spiteri wrote:
Hi 

We just implement the smartRead fix and it seems to work great on all browsers accept IE9. Any pointers please?

ikazuchi

unread,
May 23, 2013, 12:31:47 PM5/23/13
to jpl...@googlegroups.com
Do this:
header("Content-Type: application/octet-stream");
header("Content-Type: audio/mpeg"); 

Instead of this:
header("Content-Type: $mime"); 

On Saturday, November 24, 2012 4:54:27 AM UTC-8, Gabriel Spiteri wrote:
Hi 

We just implement the smartRead fix and it seems to work great on all browsers accept IE9. Any pointers please?

On Monday, May 10, 2010 9:47:57 PM UTC+2, Joe Lencioni wrote:

Ralph Theart

unread,
Jun 27, 2013, 12:57:08 PM6/27/13
to jpl...@googlegroups.com
Does this php solution work for m3u8 streams as well?

Nasir Uddin Ahmed

unread,
Oct 15, 2013, 9:11:52 PM10/15/13
to jpl...@googlegroups.com
@h4ni How do you do it? can you help me please.


Marek FlashT Rucinski

unread,
Oct 16, 2013, 10:28:27 AM10/16/13
to jpl...@googlegroups.com
The problem is not a player itself, but movie file metadata is missing or incorrect. Try this: http://ffmpeg.zeranoe.com/blog/?p=59 it helped me.


2013/10/16 Nasir Uddin Ahmed <nasir...@gmail.com>
@h4ni How do you do it? can you help me please.


--
You received this message because you are subscribed to a topic in the Google Groups "jPlayer: HTML5 Audio & Video for jQuery" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/jplayer/nSM2UmnSKKA/unsubscribe.
To unsubscribe from this group and all its topics, send an email to jplayer+u...@googlegroups.com.

To post to this group, send email to jpl...@googlegroups.com.

Nasir Uddin Ahmed

unread,
Oct 20, 2013, 10:57:05 AM10/20/13
to jpl...@googlegroups.com
Hi... i have also a seek problem with jplayer  Can Mark help me?


SERVER RESPONSE: HTTP/1.1 200 OK
Date: Sun, 20 Oct 2013 14:33:19 GMT
Server: Apache
Cache-Control: public, must-revalidate, max-age=0
Pragma: no-cache
Accept-Ranges: bytes
Content-Disposition: inline; filename=myfile.mp3
Content-Transfer-Encoding: binary
Content-Length: 8874824
Last-Modified: Sun, 20 Oct 2013 06:59:25 GMT
Vary: Accept-Encoding
X-UA-Compatible: IE=edge,chrome=1
Content-Type: audio/mpeg

Hal

unread,
Dec 9, 2013, 7:13:39 PM12/9/13
to jpl...@googlegroups.com
Hi Mark,
 
The way to hide by downloading video file with the file of smartReadFile.php works for me across ie,chrome,firefox,opera, but not on safari (even the safari is on iOS7.0.4).
 
So I have to add the true video path in jPlayer for safari.
 
Is there other way to hide video on safari browser?
 
thanks

Mark Panaghiston

unread,
Dec 10, 2013, 2:56:40 AM12/10/13
to jpl...@googlegroups.com
I understood that it did work for safari.
You are not trying to autoplay it on iOS are you?
 - Because that would not work and is a different issue entirely. iOS inhibit autoplay.

sanb...@gmail.com

unread,
Dec 22, 2013, 10:34:33 AM12/22/13
to jpl...@googlegroups.com
For the life of me, I could not get this code to work for me out of the box.

I had to add the following line (to signal a redirect from the initial request) after the possible '404' and '505' responses:

header("Location: $location");

Jill Earles

unread,
Feb 26, 2014, 4:19:09 AM2/26/14
to jpl...@googlegroups.com
Hi Mark,

I've just been trying to set this up to hide the location of my audio files, and am having trouble getting it to work.  I'm trying to use the smartReadFile.php attached here, and it's currently working on Mac 10.7.5 in Chrome 33.0 and Opera 19.0, but not in Firefox 27.0.1 or Safari 6.1.1; on Windows 7 Pro, it's currently working in Safari 5.1.7, not working in Firefox 27.0.1, not working in IE 11 (those are all the browsers I have readily available for testing).  I've tried some of the suggestions others have posted here (adding header("Content-Type: application/octet-stream"); and header("Location: $location"); but took them back out since they didn't help.  Here is my code:

require_once('smartReadFile.php');

// Get name passed via URL
$code = $_GET['file'];
$basePath = 'media/';

// Translate into real filename
switch ($code) {
    case 'm39Hek.mp3':
        $track = 'realFilename.mp3';
        $type = 'audio/mpeg, audio/x-mpeg, audio/x-mpeg-3, audio/mpeg3';
        break;
     case 'm39Hek.ogg':
        $track = 'realFilename.ogg';
        $type = 'audio/ogg, audio/x-ogg, application/ogg, application/x-ogg';
        break;
    default:
        $track = '';
}
$path = $basePath.$track;

smartReadFile($path, $track, $type);

You can test this at http://coastsolitude.com/test/, login with username: help, password: jPlayer.  

Thank you very much for your help. Have a good day.

Jill

Mark Panaghiston

unread,
Feb 26, 2014, 7:27:27 PM2/26/14
to jpl...@googlegroups.com
I took a look Jill... Full marks for having it setup online and easy to review.

On inspection under Win 7 Firefox 27.0.1, i was able to duplicate the problem. So I looked at the media url directly:
http://coastsolitude.com/test/media.php?file=m39Hek.ogg

Firefox spat that out with a download link. It should play it natively... This means that the MIME types are not acceptable.
The same happened with the mp3 version url.

I just looked around a little to see if you can specify multiple mime types... But i could not find anything. Change the types to:
MP3:
$type = 'audio/mpeg';

OGG:
$type = 'audio/ogg';

And you'll be fine.

Jill Earles

unread,
Feb 26, 2014, 7:43:15 PM2/26/14
to jpl...@googlegroups.com
Mark, Thank you very much for looking into this.  I've updated the MIME types to only one per extension as you recommended, and this fixed it in all the browsers I have (including Torch 25.0 on Mac, which I forgot to mention), except Safari on Mac, which is pretty important.  It does work on my iPhone, so am hoping that means it works on iPad Safari versions as well (will get a friend to check).  

I've done a lot of searching for possible solutions (which is how I ended up with multiple MIME types), but haven't found anything that works in Safari on Mac OS 10.7.5.  I'll ask some friends to test Safari on Mac also in case it's something specific to my computer.  Do you have a Mac available on which to test this?

Thanks again for your help.  This is much closer!  Have a good night.

Mark Panaghiston

unread,
Feb 26, 2014, 8:25:16 PM2/26/14
to jpl...@googlegroups.com
That is an older mac OS... What version of Safari does that support?
(I'm assuming you keep the Mac updated.)

Also, try visiting the URL directly on the mac and see if it works or "what happens".

Consider that the browser might be trying to play using Flash, so review your Flash version. But, jplayer should have flagged that... It was showing a friend jPlayer on his old Mac, many moons ago, that prompted me to add in the no-solution message. Meaning you should see that if Flash is old and the browser is not html5 media.

I am doing a review now on OSX 1.9.1 Safari 7.0.1
Yep, It does not work here either.

Gah! It's a new mac and I can't find the developer tools option - Ah yes! In the preferences, the very last option LOL.

Using the dev tools it says...
Type: Other
Status: -
Cached: No
Size: -
Transfered: -

I looked at the Chrome dev tools since they seem to actually let you see the response header. <rant>Safari try too hard LOL and give tons of info that no-one gives a crap about. But having said that, the interesting thing Safari tools spat out was that jPlayer generated an error event, which would usually be trickier to spot without adding stuff to the page.</rant>

Back to the response header... Maybe the default response of the smartreadfile is slightly incorrect after all...
It appears to by default return a 206 partial content response... Normally it should give a different response when the range request says "give me everything". Maybe that is what Safari is suspicious of the response...

As a test, I pasted the URL direct into safari... I did the OGG 1st in error and it downloaded and plays from my download folder just fine in VLC... So I then tried the mp3 and the Safari dev tools showed the error. Still rather cryptic...

OK, I would need to look into this. i'll get back to you.

Jill Earles

unread,
Feb 26, 2014, 8:37:57 PM2/26/14
to jpl...@googlegroups.com
My Safari version currently is 6.1.1, and I just tried to run Software Update and it failed (may need to restart or something).  I had a couple of friends test, one in 7.0.1, and one in 6.0.5, and both failed.  When going to media.php directly, with the mp3 version which Safari is said to support, it just says "loading", but never loads.  Will try to see what I can using Safari Developer Tools also (haven't used those much).  

Thanks so much for your help with this.  I really like jPlayer.

Mark Panaghiston

unread,
Feb 26, 2014, 8:53:05 PM2/26/14
to jpl...@googlegroups.com
No changes yet, but I put the PHP file onto a more sensible system:
https://github.com/happyworm/smartReadFile

Still need to add in some nods to the original devs... Eoin got credit, but there was an earlier contributor that did the very first version... It was a long time ago now.

I plan to maintain the file in the github repo from now on and will report beck here if i have any success... I plan to setup a demo on the jplayer.org site that uses it.

One thing... I have never actually used this file, but I wondered if this PHP API is a security risk... Send in the media file url of /etc/some/path and get the text file spewed out into the browser.

Your thought?

Jill Earles

unread,
Feb 26, 2014, 9:25:56 PM2/26/14
to jpl...@googlegroups.com
Would you say more about what you're thinking regarding the security risk?

Definitely worth making sure you sanitize what's sent into it.  The way my code uses it is with a switch, so that only the "codes" I put in my playlist js file will do anything.  Could be other risks I'm not thinking of though.



Jill Earles

unread,
Feb 26, 2014, 9:32:31 PM2/26/14
to jpl...@googlegroups.com
Thanks for putting this on github, and am pleased that you used my code for the example.  :)

Glad you think this is worth adding to jplayer.org with a demo.

Jill Earles

unread,
Feb 26, 2014, 9:46:31 PM2/26/14
to jpl...@googlegroups.com
Just realized something you said earlier could be an issue too:

" I did the OGG 1st in error and it downloaded and plays from my download folder just fine in VLC…"

The whole point of this (for me at least) is to prevent downloading, while allowing the audio to be played through jPlayer.  

Related to that, during my research of this, I found something that said that Safari on Mac uses QuickTime for playing audio and video.  There's a setting on our web host that's designed to prevent downloading of specified file types and it says that for files to be played in QuickTime on Mac, you have to allow direct linking (which enables downloading), and I was able to verify that Safari would not play audio when direct linking was not allowed and would play it when it was allowed (using the direct path to the files in the playlist js, no php).  That's when I started looking for a PHP solution.



Mark Panaghiston

unread,
Feb 26, 2014, 11:49:58 PM2/26/14
to jpl...@googlegroups.com
@Jill: I used your code as a starting point... I then let it evolve. I think the 1st and last lines remain the same now ;) It was a fine seed, and I like seeds. Respect! <chest thump>

Current info for group:

1) I added a security whitelist. Expand list as required, but never include / since that is never in a sensible filename. Failure gives 404.
2) Grabs the type from the file extension for common extensions. Well, the sensible one... If you want to use a WAV then, as the emperor says, "So be it." But you can add it :P

@Jil: To disable access you should be checking for rights in the PHP before you call smartReadFile(). For example, you can use the session and have a user/login system and then check the session before serving the file. If they are not logged in, which you'd check on the session, you then give a 404 error or you could be horrible and server a highly (sound spectrum) compressed and normalized white noise signal... Or a loud sine wave, since they have a lot of power and are annoying.

I will add a comment about this to the example code... I've not actually touched the smartReadFile.php itself yet. I'm getting all the boring shite out the way first.

Sinisa Novakovic

unread,
Feb 27, 2014, 12:21:55 AM2/27/14
to jpl...@googlegroups.com
Don't you people do anything else in your lives except waisting your time sending e-mails to each about this bullshit player?

/:-))


Date: Wed, 26 Feb 2014 20:49:58 -0800
From: mark.pan...@gmail.com

To: jpl...@googlegroups.com
Subject: Re: [jPlayer] Re: Trouble with seek and stop button

You received this message because you are subscribed to the Google Groups "jPlayer: HTML5 Audio & Video for jQuery" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jplayer+u...@googlegroups.com.

Mark Panaghiston

unread,
Feb 27, 2014, 12:41:48 AM2/27/14
to jpl...@googlegroups.com, sille_n...@hotmail.com
@Sinisa: Well I have my cat Lenny. I spend a significant amount of time recovering from the wounds I receive while petting him. When not administering first aid to a circulatory injury, I enjoy writing JavaScript code and attempting to educate others on how to use it. I used to take long walks in the country, but it is a tad cold out there at this time of year and my long years sitting on my derrière have not been kind. Instead, I spend my time helping others achieve their goals, while trying not to bleed on anything important.

If you find the emails too much, you can adjust your settings on the Google Group website. The vast majority choose to receive no emails and they only receive emails from threads they have commented on. They seem happy, all 5700 of them.

What do you spend your evenings doing when exhausted from trolling?

Might I dare to suggest you take a look at this:
http://earth.nullschool.net/

I find it quite soothing and it suppresses my desires to destroy those who cross me :D

Mark Panaghiston

unread,
Feb 27, 2014, 1:01:14 AM2/27/14
to jpl...@googlegroups.com, sille_n...@hotmail.com
@Jill: OK well this is confusing, but it is a clue... When accessing the github demo over my LAN from the same Mac that had problems on your site, it worked just fine.

This reminds me... in the past there used to be issues with Safari when on an AUTH restricted area. Test it on a hidden area that is not restricted through .htaccess / Apache authentication and see if that works. The problem used to be if the media was authenticated, but the page was open, but it is worth reviewing. You'll not have the clunky Apache HTTPD authentication happening when your site is live. Or will you?

Jill Earles

unread,
Feb 27, 2014, 1:12:32 AM2/27/14
to jpl...@googlegroups.com
@Mark - No, no apache basic auth on the live site :).  Live site doesn't require login at all (which is why we want to hide location of the audio files/prevent download).  I'll check it without that and let you know how it goes (after eating dinner; very late getting to that tonight).  Thanks for remembering this.  

Jill Earles

unread,
Feb 27, 2014, 1:20:35 AM2/27/14
to jpl...@googlegroups.com
@Mark: I lied.  Went ahead and tested this before eating.  Doesn't work.  Thanks for the suggestion anyway.  

P.S.  I very much like http://earth.nullschool.net.  Thanks for sharing (and hope your wounds aren't deep).

Mark Panaghiston

unread,
Feb 27, 2014, 1:22:03 AM2/27/14
to jpl...@googlegroups.com
@Jill: I have a feeling that you missed the point of this PHP smartReadFile() function... It will server the file in the same way (we believe) as a server would server any other static media file url. if you do not have any authentication system, then using it is pointless.

Mark Panaghiston

unread,
Feb 27, 2014, 2:06:37 AM2/27/14
to jpl...@googlegroups.com
@Jill: I have just setup a .htaccess Basic Auth on my localhost, and tested on my Mac. The one with Auth fails. The one without Auth works.

Please double check your tests.

You say that you have a version online without auth, please give its url and I'll look. This "look" will probably be tomorrow, well, later today. It is way past last, through early, and is now a respectable time to be getting up in the morning. I'm off to bed!

Jill Earles

unread,
Feb 27, 2014, 2:23:04 AM2/27/14
to jpl...@googlegroups.com
@Mark - Thanks.  I'll test again, and will think more about (and ask the artist) whether obscuring the the files' location, and restricting access to media.php by referrer, etc. will be "secure" enough.  Sleep well.

Jill Earles

unread,
Feb 27, 2014, 2:26:02 AM2/27/14
to jpl...@googlegroups.com

Jill Earles

unread,
Feb 27, 2014, 2:57:31 AM2/27/14
to jpl...@googlegroups.com
@Mark: Yep, you were right.  I had forgotten that I had used a full path to /test/media.php in my js file.  Works now in Safari.  Thank you very much.

Now, to put extra measures in place to make it less easy to download… (suggestions appreciated).  

Oh, right.  Sleep first.  'Til tomorrow...

Mark Panaghiston

unread,
Feb 27, 2014, 3:23:26 AM2/27/14
to jpl...@googlegroups.com
@Jill: Sweet! Yes, put the login/registration requirement in or otherwise all the smartReadFile.php does is slow down your server and has no benefit at all!

All is good though. We now have a kick ass smartReadFile() GitHub repo with a demo in it ready for people to use... I have updated the known issues to say:
  • When this project is behind Apache AuthType, OSX Safari refuses to play the media served.
BTW, I have not changed the smartReadfile.php at all.

Now i should update the jPlayer support page... I'll leave the link to this epic thread in there... It has thousands of views and is a good port of call.

Jill Earless

unread,
Feb 27, 2014, 3:43:07 AM2/27/14
to jpl...@googlegroups.com
@Mark:  login requirement won't work for this - the whole point is to let people hear some of his music (and in full quality). Will try to add some obscurations though. Will talk more about this with the artist tomorrow. 

Still feels like a partial success. Thanks again for all of your help. 

Mark Panaghiston

unread,
Feb 27, 2014, 3:54:22 AM2/27/14
to jpl...@googlegroups.com
@Jill: The key word here is "some":

the whole point is to let people hear some of his music

Create "some" audio files previewing "some" of the music and forget about this smartReadFile.php stuff. It is doing nothing for you useless you use it to restrict access through an authentication system. Assume that anything someone can download on the internet is OPEN. Do not put anything online that you do not want to give away for free.

An alternative is to use really poor encoding on the files you preview, but most musicians/sound engineers I know want insane levels of quality beyond 1 minute old baby hearing and think 192kbs stinks. Most videos are lower quality than these audio files LOL. But the point is, if you want to demo it all, demo low quality "all" and high quality "snips". Then they can pay for (or whatever) the high quality "all" files.

Ernest Cheung

unread,
Mar 7, 2014, 12:48:39 PM3/7/14
to jpl...@googlegroups.com
I am really appreciated with this piece of code, it helps me out while I was puzzling why my own PHP read file doesn't work!

However, after implementation, there are a few problems encountering:

1. For some device (like my own Android 4.1.2 Chrome 33.0.1750.136), it just cannot manage to have the seek function.  I implemented the JPlayer HTML5 inspector and it turns out that, if I directly play the audio on my phone, it is seekable, but if I use this code it is still not seekable.  Link to test page:
http://www.wongsir.com.hk/test.php <-- Using smartReadFile 
http://www.wongsir.com.hk/testb.php <--- Direct file access 

2. And secondly, there are bunches of users reporting a disconnect issue, where they play the file, and it suddenly just stopped and jump back to the starting point.  But none of my team have encountered such issue, and therefore we have totally no clue on this matter, is there anyone facing the same issue?

It would be great if anyone could advice or share your experience on the similar issue, so that I could have a precise direction to work on improving the code.

Thanks & Regards,
Ernest

Mark Panaghiston於 2014年2月27日星期四UTC+8上午9時53分05秒寫道:

Mark Panaghiston

unread,
Mar 7, 2014, 4:23:16 PM3/7/14
to jpl...@googlegroups.com
Android phones have issues... The vendors are not bothered about fixing their media html5 drivers. Only google get it right. Samsung are fail. Maybe that is your problem... Ask Samsung not to suck as much.

Ernest Cheung

unread,
Mar 7, 2014, 11:41:28 PM3/7/14
to jpl...@googlegroups.com

Mark,

Thanks for your prompt reply.
You are right, I am exactly using Samsung note 2. 

But apart from kicking Samsung's ass, could you advice a bit more clue on what exactly is the problem with their html5 driver?

I meant, I thought using PHP can completely simulate a file, and thus it should not merely suck with PHP but works with the file implementation.  Do you have any idea on that?

By the way, the disconnect issue indeed does not appear on my sucking Samsung phone.  It instead appear everywhere except in my team's phone, any idea on this issue?

Many thanks again!

Cheers,
Ernest

--
You received this message because you are subscribed to a topic in the Google Groups "jPlayer: HTML5 Audio & Video for jQuery" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/jplayer/nSM2UmnSKKA/unsubscribe.
To unsubscribe from this group and all its topics, send an email to jplayer+u...@googlegroups.com.
To post to this group, send email to jpl...@googlegroups.com.
Visit this group at http://groups.google.com/group/jplayer.
For more options, visit https://groups.google.com/d/optout.

Mark Panaghiston

unread,
Mar 8, 2014, 5:33:34 AM3/8/14
to jpl...@googlegroups.com
I should not have posted last night. I'd let my hair down, all 3mm of it, and had a drink. I sometimes get frustrated with the Android question. Most devs tend to think the sun shines out its ass, and I seem to be the only one that bangs heads with its operation.

As to the problem... We recently decided that this fix to the playlist would be applied to the core.
https://groups.google.com/d/msg/jplayer/MMm3BXFShqc/JlIL5tpmp3YJ

It is a simplification of the full Android 2.3 fix shown here:
http://jplayer.org/latest/developer-guide/#jPlayer-known-issues-android
http://jplayer.org/latest/demo-01-android/

The idea being with the simplification, that the media - read audio - should always at least play. If the ended event does not happpen in some ancient Android version then that is too bad. But the audio should at least play when he user pressed the play button or changes the track manually.

Now your issue does sound different.
You might want to consider that your media is not encoded correctly. I am not sure how new or old the Samsung note 2 is... I did try and investigate last weekend, but they have a large array of devices avaiable and the only way to tell which is newer, seems to be to look at the price tag, or delve into the technical specs. But I digress.

[OK now I'm grumpy... The info is valid.. Just not sugar coated.]

Actually... After looking closely... It looks like it is you that have failed.

Fail 1... You GZIP the media data... You do realize that media is higly compressed already? That is the whole point of the different audio formats, compression. GZIPing the media data is a waste of time and CPU power and also affects the playback in the browser.

Learn to use your dev tools. Look at the response of this URL in the browser:
http://wongsir.com.hk/testRegistrar.php?req=test.mp3

Content-Encoding: gzip
content-transfer-encoding: binary

http://jplayer.org/latest/developer-guide/#jPlayer-server-response

Do Not GZIP the Media

Disable GZIP encoding of all the media files. Media files are already compressed and the GZIP will just waste CPU on your server.

The Adobe Flash Plugin will experience issues if you GZIP the media.

Do not GZIP the Jplayer.swf file either. Feel free to GZIP the JavaScript.


So fix your server response and remove the GZIPing and I am sure your problem will go away.

It looks like I need to add Android to that list of GZIP weaknesses.

Ernest Cheung

unread,
Mar 8, 2014, 12:03:18 PM3/8/14
to jpl...@googlegroups.com
Mark,

You are just epic great!   

Sorry that I cannot find out the GZip problem: actually I gone through the develop guide, but the wired thing is... I don't see that Content-Encoding: gzip in the respond to my PC Chrome which I used dev tools there. 

The problem now solved by simply adding this to the smartFileReader.php:

    header("Content-Encoding: none");

May be you should consider to add this also into the source, to avoid people like me making such silly mistake?

Anyone, do you think that this is also the solution to the disconnection problem?  Actually what bother me most is about the disconnection:
Everyone in my team with all their device works well.
But there are substantial number of users reporting constant disconnection.  For a 30 minute audio, some of them report that they may need to reconnect 3 times to listen the entire file.
I have solved some of them by spotting out that it is actually the lock screen problem, but still there are some of them claiming that they are using PC to listen.

Once again, Many thanks!

Mark Panaghiston於 2014年3月8日星期六UTC+8下午6時33分34秒寫道:

Mark Panaghiston

unread,
Mar 8, 2014, 12:36:36 PM3/8/14
to jpl...@googlegroups.com
FYI: That Android fix I mentioned, has now been uploaded to github, tagged as jPlayer 2.5.5.

For the moment, I will add an issue to the smartRedFile repo about the GZIP disabling header. I'll probably get time later, but I do sometimes like to have a little bit of a weekend. Thanks for the info on that.

Can we please recap on the disconnection problem. I have this info from your posts:
  • There are bunches of users reporting a disconnect issue, where they play the file, and it suddenly just stopped and jump back to the starting point.  But none of my team have encountered such issue, and therefore we have totally no clue on this matter, is there anyone facing the same issue?
  • By the way, the disconnect issue indeed does not appear on my Samsung phone. It instead appear everywhere except in my team's phone, any idea on this issue?
  • Everyone in my team with all their device works well.
    But there are substantial number of users reporting constant disconnection.  For a 30 minute audio, some of them report that they may need to reconnect 3 times to listen the entire file. I have solved some of them by spotting out that it is actually the lock screen problem, but still there are some of them claiming that they are using PC to listen.
    Ah ok... Reading it all like that make more sense... So this is nothing to do with Android. Phew! My eyebrow was starting to twitch.

    I will need to have a think about this over dinner... And maybe I'll find some time to play with your demo. I had thought that turning off the GZIP would solve both problems, since my Firefox browser was behaving a little off with the smartReadFile GZIPed output too.

    Johno

    unread,
    Mar 19, 2014, 7:43:15 PM3/19/14
    to jpl...@googlegroups.com
    Cannot get jplayer to stream via the SmartReadFile on Safari (works perfectly in Chrome), looks like others encountered this previously? have played about with all the various Mime types etc and no joy - has this been resolved? Does this now work on Safari for anyone?

    thanks, J

    Jill Earles

    unread,
    Mar 20, 2014, 1:26:56 AM3/20/14
    to jpl...@googlegroups.com
    @Johno: Is there any kind of authentication on the directory in which you're using this?  I was able to get it working in Safari by moving it to a directory that was not restricted by apache basic authentication.  

    janagani nagaraju

    unread,
    Feb 4, 2017, 12:45:05 PM2/4/17
    to jPlayer: HTML5 Audio & Video for jQuery
    Hi 
    here iam using the jplayer 
    but it is working one server and not working other server
    is there any server configuration?

    Not working link this is QA server ip is 199.79.62.18

    Working here the same script




    Reply all
    Reply to author
    Forward
    0 new messages