Order Now AdSolution Sign Up | Login » Bits on the Run Sign Up | Login »

Forums

/

Strange behavior depending on loading the playlist.

42 replies [Last post]
Reply

I managed to get JWplayer 5.7 going with playlist I load into player.
Both on PC's and on my iPhone (IOS 5.x).

So far i am fine.

Then I wrote a php script to read a directory with MP3's. This script exactly (as far as I know) generates the same XML file as the "hardcopy" of the file on the server.

On the PC it plays fine, on the iPhone not. The playlist on the iPhone is empty. It seems to me that it loads in flash on the PC and does not change to html5 on the iPhone. Although the playlist.xml file (hardcoded or generated) show exactly the same in the browser (view source).

<script type='text/javascript'>
    jwplayer('mediaspace').setup({
//        'playlistfile': './media/music/Arena - Immortal/playlist.xml',
        'playlistfile': './dir_list/playlist.php',
        'flashplayer': './jwplayer/player.swf',
        'playlist.position': 'right',
        'playlist.size': '400',
        'bufferlength': '5',
        'mute': 'false',
        'controlbar': 'bottom',
        'width': '400',
        'height': '200',
        'repeat' : 'list',
        'volume' : '100',
        'stretching' : 'none',
        'quality' : 'false',
        'lightcolor' : 'CCCCCC',
        'frontcolor' : 'FFFFFF',
        'logo.hide' : 'false',
        'shuffle' : 'false',
        'skin' : './jwplayer/stylish_slim.swf',
        'shownavigation': 'true',
    });
</script>

Notice the playlistfile lines.

'playlistfile': './media/music/Arena - Immortal/playlist.xml',

Does work.

'playlistfile': './dir_list/playlist.php',

Does not.
playlist.php generates the playlist file, see:
www.2rsweb.nl/progstreaming_test/dir_list/playlist.php (then view source).

The player can be found at:
www.2rsweb.nl/progstreaming_test

Anyone can give me a hint?

Reply

Something I like to add:

check url www.2rsweb.nl/progstreaming_test/indexok

to see the version which does work, because it uses the playlist.xml file.

Reply
Reply

This should be fine, can you try to upgrade to 5.9 though?

Reply

Ethan,

the "problem" with version 5.9 is that it has not the next and previous buttons (like version 5.8).

I can give it a try and see what happens.

I just tried version 5.9. And indeed, the previous and next buttons are gone.
On the PC everything works fine. On an iPhone neither of the solutions (playlist.xml or playlist.php) don't work.

Reply

Yes, they are removed from 5.8 and 5.9.

We have a demo of 5.9 and playlists here which works fine on iOS:

http://developer.longtailvideo.com/player/trunk/fl5/js/test/examples/xmlplaylists.html

Here is a sample file you can use as a template - http://developer.longtailvideo.com/player/trunk/fl5/js/test/examples/assets/mrss.xml

Reply

Ethan,

thank you for your answers. Of course I have looked at these playlist xml files before. They are different becuase you define more things to show.

I only need the title of the song(s).

Besides that, both playlists (the fixed one and the generated one) are basically the same. However, when I use the generated playlist, I does not show in iPhone, and does on a PC (five types of browsers are OK).

Fixed playlist.xml:

<rss xmlns:media="http://search.yahoo.com/mrss/" xmlns:jwplayer="http://developer.longtailvideo.com/trac/" version="2.0">
<channel>
<title>MRSS Playlist Playlist</title>
<item>
<title>01 - Chosen</title>
<jwplayer:author>Arena</jwplayer:author>
<media:content url="http://www.2rsweb.nl/progstreaming_test/media/music/Arena - Immortal/01 - Chosen.mp3"/>
</item>
<item>
<title>02 - Waiting For The Flood</title>
<jwplayer:author>Arena</jwplayer:author>
<media:content url="http://www.2rsweb.nl/progstreaming_test/media/music/Arena - Immortal/02 - Waiting For The Flood.mp3"/>
</item>
<item>
<title>03 - The Butterfly Man</title>
<jwplayer:author>Arena</jwplayer:author>
<media:content url="http://www.2rsweb.nl/progstreaming_test/media/music/Arena - Immortal/03 - The Butterfly Man.mp3"/>
</item>
<item>
<title>04 - Ghost In The Firewall</title>
<jwplayer:author>Arena</jwplayer:author>
<media:content url="http://www.2rsweb.nl/progstreaming_test/media/music/Arena - Immortal/04 - Ghost In The Firewall.mp3"/>
</item>
<item>
<title>05 - Climbing The Net</title>
<jwplayer:author>Arena</jwplayer:author>
<media:content url="http://www.2rsweb.nl/progstreaming_test/media/music/Arena - Immortal/05 - Climbing The Net.mp3"/>
</item>
<item>
<title>06 - Moviedrome</title>
<jwplayer:author>Arena</jwplayer:author>
<media:content url="http://www.2rsweb.nl/progstreaming_test/media/music/Arena - Immortal/06 - Moviedrome.mp3"/>
</item>
<item>
<title>07 - Friday's Dream</title>
<jwplayer:author>Arena</jwplayer:author>
<media:content url="http://www.2rsweb.nl/progstreaming_test/media/music/Arena - Immortal/07 - Friday's Dream.mp3"/>
</item>
</channel>
</rss>

Generated playlist (playlist.php):

<rss version="2.0" xmlns:media="http://search.yahoo.com/mrss/" xmlns:jwplayer="http://developer.longtailvideo.com/trac/">
<channel>
  <title>PHP Generated Playlist for progstreaming.com</title>
    <item>
      <title>01 - Chosen</title>
      <jwplayer:author>RON Playlist</jwplayer:author>
      <media:content url="http://www.2rsweb.nl/progstreaming_test/media/music/Arena - Immortal/01 - Chosen.mp3" />
    </item>
    <item>
      <title>02 - Waiting For The Flood</title>
      <jwplayer:author>RON Playlist</jwplayer:author>
      <media:content url="http://www.2rsweb.nl/progstreaming_test/media/music/Arena - Immortal/02 - Waiting For The Flood.mp3" />
    </item>
    <item>
      <title>03 - The Butterfly Man</title>
      <jwplayer:author>RON Playlist</jwplayer:author>
      <media:content url="http://www.2rsweb.nl/progstreaming_test/media/music/Arena - Immortal/03 - The Butterfly Man.mp3" />
    </item>
    <item>
      <title>04 - Ghost In The Firewall</title>
      <jwplayer:author>RON Playlist</jwplayer:author>
      <media:content url="http://www.2rsweb.nl/progstreaming_test/media/music/Arena - Immortal/04 - Ghost In The Firewall.mp3" />
    </item>
    <item>
      <title>05 - Climbing The Net</title>
      <jwplayer:author>RON Playlist</jwplayer:author>
      <media:content url="http://www.2rsweb.nl/progstreaming_test/media/music/Arena - Immortal/05 - Climbing The Net.mp3" />
    </item>
    <item>
      <title>06 - Moviedrome</title>
      <jwplayer:author>RON Playlist</jwplayer:author>
      <media:content url="http://www.2rsweb.nl/progstreaming_test/media/music/Arena - Immortal/06 - Moviedrome.mp3" />
    </item>
    <item>
      <title>07 - Friday's Dream</title>
      <jwplayer:author>RON Playlist</jwplayer:author>
      <media:content url="http://www.2rsweb.nl/progstreaming_test/media/music/Arena - Immortal/07 - Friday's Dream.mp3" />
    </item>
</channel>
</rss>

Actually, only the content of the fields in lines:
<title>MRSS Playlist Playlist</title>

and

<jwplayer:author>Arena</jwplayer:author>

are different.
Strange...

Reply

Hmm,

Also tried following:

Copy the generated XML code into the actual playlist.xml file.
The playlist.xml does still play ok, also in iPhone.
So, it cannot be the code generated. Must have something to do with using the php file and jwplayer in combination, especially when using html5 (iPhone).

Reply

So,

http://www.2rsweb.nl/progstreaming_test/ is the playlist.php version, which does not work on the iPhone.

http://www.2rsweb.nl/progstreaming_test/indexok.php is the playlist.xml version, which does play/show on the iPhone.

Reply

OK,

what I tried next (and why not before ;-) ).

Disabled flash in Chrome browser. And now I get the same result as with the iPhone.

http://www.2rsweb.nl/progstreaming_test/ is the playlist.php version, which does not work.

http://www.2rsweb.nl/progstreaming_test/indexok.php is the playlist.xml version, which does play/show. Although without the skin for obvious reasons. I used a flash skin.

My conclusion is that the JWplayer (or HTML5 itself) does not support a PHP generated playlist in HTML5 mode. Although the output format of the PHP script is exactly the same.

Any ideas?

Reply

It seems my problems have shifted from playlist format issues to "how to read input from playlist.php file into JWplayer".

Any suggestions?

Reply

Hmm, I think it may be a bug/issue, I don't believe dynamically generated PHP files work in HTML5 mode. Let me ask Jeroen though to confirm.

Reply

Ok, thanks. I'll wait for that.

Reply

Np, will let you know.

Reply

This is very likely due to the header of your php playlist:

1) The PHP list is served with a header of "text/html"
2) The XML list is served with a header of "application/rss+xml"

You should try to set the latter header using the simple PHP header() function. That may fix things!

Reply

HI Jeroen,

you mean something like:
'playlistfile': 'header('Location: http://localhost:8081/dir_list/playlist.php')',

At least I get something back now. Unfortunately its status 403, Forbidden.

Another way to get this doen is to write the file to the server and then read. That is not a nice as I would like it to be.

Reply

You should send this header:

header('Content-type: application/rss+xml');

Reply

Thanks Jeroen,

I could not get that to work.

So, I decided to dynamically generate a playlist file in the album directory and read that into JWplayer.

BTW, is there any chance the previous and next buttons will come back?

Reply

Hmm, that should make it work.

Do you use a playlist? Why would you want to have the prev/next buttons in the controlbar then? Isn't that a bit redundant?

Reply

Jeroen,

I do not why I can not get that to work.
Where should I add that header(..). After playlistfile: ?

It is not really important to use previous and next buttons. It is just handy, because we eventually will us player on a website where you can listen to new music and skip/checkout tracks easily.

Reply

The header() command should be placed before you do the first echo or print to the browser.

Reply

Ah, right.

Will give it a try later this week.

Thanks for the support.

Reply

Jeroen,

this really seems to work now. Great.
I have to do some additional testing.

If you think it is helpfull, I can post the code.

Thanks for your help

Reply

OK, cool!

Reply

Do you want the code too?

Reply

A code snippet would probably be very helpful for others indeed. Thanks!

Reply

OK here it is.

The player reads in a dynamically generated XML playlist. See the line with "playlistfile". Instead of reading a playlist.xml file, a playlist.php file is called. This php file will generate a xml file dynamically by reading a directory (as defined in $album) with MP3 files.

<script type='text/javascript'>
    jwplayer('mediaspace').setup({
// Call playlist.php script with the album name ($album)
        'playlistfile': './playlist.php?album=<?php echo $album; ?>',
// Location of JWplayer
        'flashplayer': 'http://yourwebsite.com/jwplayer/player.swf',
// Location and size of playlist
        'playlist.position': 'right',
        'playlist.size': '400',
// Start playing at 5 seconds of music/video are buffered
        'bufferlength': '5',
// Do not show mute button
        'mute': 'false',
// Location of controlbar
        'controlbar': 'bottom',
        'width': '400',
        'height': '200',
// Show list, do not repeat
        'repeat' : 'list',
// Set default volume to 100%
        'volume' : '100',
        'stretching' : 'none',
        'quality' : 'false',
// Define playlist and text colors
        'lightcolor' : 'CCCCCC',
        'frontcolor' : 'FFFFFF',
// Logo can only be hidden with licensed version
        'logo.hide' : 'false',
// Do not show shuffle button
        'shuffle' : 'false',
// Use modieus skin (works for flash and html5)
        'skin' : 'http://yourwebsite.com/jwplayer/modieus/modieus.xml',
// Show navigationbar
        'shownavigation': 'true',
// use Google Analytics add-in (need account)
        'plugins': {'gapro-2': {
                                'gapro.accountid': 'UA-xxxxxxxx-x',
                                'trackstarts':     'true',
                                'trackpercentage': 'true',
                                'tracktime':       'true'
                              }
        },
    });
</script>

You have to make sure to use the header() function in the playlist.php file to define the output of the php file as xml/text.

Extract from playlist.php:

// Set header to be rss/xml type of data. Before sent back to previous php file
header('Content-type: application/rss+xml');

// Write header of rss XML file tp $playlist variable
$playlist="<rss version="2.0" xmlns:media="http://search.yahoo.com/mrss/" xmlns:jwplayer="http://developer.longtailvideo.com/trac/">n";
$playlist=$playlist . "<channel>n";
$playlist=$playlist . "  <title>PHP Generated Playlist for progstreaming.com</title>n";

// ...then we loop through the array...
foreach($items as $key => $value)
// Array $value holds the file name(s) until all files are red

{

// Discard every file, except mp3 (as defined in $filter) files, done by checking extention of file(s)
  if (substr($value, (strlen($value)-4), (strlen($value)-(strlen($value)-4)))==$filter)

    {

// Get $title by stripping the extention from filename(s)
  $title = substr($value, 0, strlen($value) - 4);

// Write XML segments
  $playlist=$playlist . "    <item>n";
  $playlist=$playlist . "      <title>" . $title . "</title>n";
  $playlist=$playlist . "      <media:content url="" . 'http://' . $url . $abs_music_directory . $active_directory . '/' . $value . "" />n";
  $playlist=$playlist . "    </item>n";

    }
}

// ...and last we add the closing tags
$playlist=$playlist . "</channel>n";
$playlist=$playlist . "</rss>nn";

// print value of $playlist variable
// Because header is set as text, the output is sent to previous php file as rss/text
echo $playlist;

Part of the above code taken from this forum. See:
http://www.longtailvideo.com/support/forums/jw-player/using-playlists/6534/autogenerate-playlist-fro....

Reply

Cool, thanks!

Reply

Hi, Ron, i am trying to get this working on my Linux site. where is the folder directory name & path to the .mp3s? where do i change it, I am calling mine, mp3. what elements to change in the php script to point to it?

Reply

@woc100 - it can be anywhere as long as your code is referencing it correctly.

Reply

I just changed the domain name to mine, the path to my mp3s are.../player/mp3
heres what i have now:

index.html here:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>
<title>HTML5/Flash test for mydomain.com</title>
<META HTTP-EQUIV="CACHE-CONTROL" CONTENT="NO-CACHE">

<!-- Google Analytics -->
<script type="text/javascript">

var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-29237868-1']);
_gaq.push(['_trackPageview']);

(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();

</script>

<script type='text/javascript' src='http://www.mydomain.com/mediaplayer/jwplayer.js'></script>

</head>

<body>

<font style="font-family:Arial; font-size:16px">HTML5/Flash test for <a href="http://mydomain.com" target="_blank" title="mydomain.com">mydomain.com</a></font>
<br />

<a href="http://www.mydomain.com/player/index.php?album=IO Earth - Moments">IO Earth - Moments</a>
<br />
<a href="http://www.mydomain.com/player/index.php?album=Arena - Immortal">Arena - Immortal</a>
<br />
<a href="http://www.mydomain.com/player/index.php?album=Arena - Live At Krakow">Arena - Live At Krakow</a>
<br />
<br />

<!-- Define table with cover art and Jwplayer with playlist -->
<table cellpadding="0" cellspacing="0">
<tr>
<td><img src="http://www.mydomain.com/player/images/.jpg" height="380" width="380"></td>
<td valign="top" width="400" height="200">
<table cellpadding="0" cellspacing="0">
<tr>
<td bgcolor=#C0C0C0>
<font style="font-family:Arial; font-size:12px">
<b>  Playlist</b>
</font>
</td>
</tr>
<tr>
<td>
<!-- If flash is not installed or not enabled, show loaction to download -->
<!-- "mediaspace" will be replaced by the script below -->
<div id='mediaspace'>Please, install <a href="http://get.adobe.com/nl/flashplayer/" target="_blank" title="Get Adobe Flash player">Adobe Flash</a> or use a HTML5 enabled browser</div>
</td>
</tr>
</table>
</td>
</tr>
</table>

<script type='text/javascript'>
jwplayer('mediaspace').setup({
'playlistfile': './dir_list/playlist.php?album=not_found',
'flashplayer': 'http://www.mydomain.com/mediaplayer/player.swf',
'playlist.position': 'right',
'playlist.size': '400',
'bufferlength': '5',
'mute': 'false',
'controlbar': 'bottom',
'width': '400',
'height': '200',
'repeat' : 'list',
'volume' : '100',
'stretching' : 'none',
'quality' : 'false',
'lightcolor' : 'CCCCCC',
'frontcolor' : 'FFFFFF',
'logo.hide' : 'false',
'shuffle' : 'false',
'skin' : 'http://www.mydomain.com/mediaplayer/modieus/modieus.xml',
'shownavigation': 'true',
'plugins': 'quickkeys-1',
'plugins': {'gapro-2': {
'gapro.accountid': 'UA-29237868-1',
'trackstarts': 'true',
'trackpercentage': 'true',
'tracktime': 'true'
}
},
});
</script>

</body>

playlist.xml here:

<script type='text/javascript'>
    jwplayer('mediaspace').setup({
// Call playlist.php script with the album name ($album)
        'playlistfile': 'http://mydomain.com/player/playlist.php?album=<?php echo $album; ?>',
// Location of JWplayer
        'flashplayer': 'http://mydomain.com/mediaplayer/player.swf',
// Location and size of playlist
        'playlist.position': 'right',
        'playlist.size': '400',
// Start playing at 5 seconds of music/video are buffered
        'bufferlength': '5',
// Do not show mute button
        'mute': 'false',
// Location of controlbar
        'controlbar': 'bottom',
        'width': '400',
        'height': '200',
// Show list, do not repeat
        'repeat' : 'list',
// Set default volume to 100%
        'volume' : '100',
        'stretching' : 'none',
        'quality' : 'false',
// Define playlist and text colors
        'lightcolor' : 'CCCCCC',
        'frontcolor' : 'FFFFFF',
// Logo can only be hidden with licensed version
        'logo.hide' : 'false',
// Do not show shuffle button
        'shuffle' : 'false',
// Use modieus skin (works for flash and html5)
        'skin' : 'http://mydomain.com/mediaplayer/modieus/modieus.xml',
// Show navigationbar
        'shownavigation': 'true',
// use Google Analytics add-in (need account)
        'plugins': {'gapro-2': {
                                'gapro.accountid': 'UA-xxxxxxxx-x',
                                'trackstarts':     'true',
                                'trackpercentage': 'true',
                                'tracktime':       'true'
                              }
        },
    });
</script>

playlist.php here:

// Set header to be rss/xml type of data. Before sent back to previous php file
header('Content-type: application/rss+xml');
// Write header of rss XML file tp $playlist variable?$playlist="<rss version="2.0" xmlns:media="http://search.yahoo.com/mrss/" xmlns:jwplayer="http://developer.longtailvideo.com/trac/">n";?$playlist=$playlist . "<channel>n";?$playlist=$playlist . "  <title>PHP Generated Playlist for mydomain.com</title>n";
// ...then we loop through the array...?foreach($items as $key => $value)?// Array $value holds the file name(s) until all files are red
{
// Discard every file, except mp3 (as defined in $filter) files, done by checking extention of file(s)?  if (substr($value, (strlen($value)-4), (strlen($value)-(strlen($value)-4)))==$filter)
    {
// Get $title by stripping the extention from filename(s)?  $title = substr($value, 0, strlen($value) - 4);
// Write XML segments?  $playlist=$playlist . "    <item>n";?  $playlist=$playlist . "      <title>" . $title . "</title>n";?  $playlist=$playlist . "      <media:content url="" . 'http://' . $url . $abs_music_directory . $active_directory . '/' . $value . "" />n";?  $playlist=$playlist . "    </item>n";
    }?}
// ...and last we add the closing tags?$playlist=$playlist . "</channel>n";?$playlist=$playlist . "</rss>nn";
// print value of $playlist variable?// Because header is set as text, the output is sent to previous php file as rss/text?echo $playlist;

Reply

Ok - can I see where this is running?

Reply

I am having similar issues and can't see what I am doing wrong. My code is almost identical to Rons shown above. However I get the not a valid playlist. I am using header as descibed, and if I take the output from the php script and feed it to a file and then load that file as the playlist it works.

I paste the playlist-flv.php below for reference, the test page is here

http://www.thinqdifferently.com/playlistsecure.php

<?php

$creator = "test";
$filter = ".mov";
$directory = "videos/";

@$d = dir($directory);

if ($d){
while($entry = $d->read()){
$ps = strpos(strtolower($entry), $filter);
if (!($ps === false)){
$items[$entry]['mtime'] = filemtime($entry);
}

}
$d->close();
arsort($items);

header('content-type:application/rss+xml');
echo "<?xml version='1.0' encoding='utf-8'?>n";
echo "<rss version="2.0" xmlns:jwplayer="http://developer.longtailvideo.com/trac/" xmlns:media="http://search.yahoo.com/mrss/">";
echo " <channel>";
echo " <title>Playlist</title>";

foreach($items as $key => $value){
$title = substr($key, 0, strlen($key) - 4);
echo " <item>";
echo " <title>" . $title . "</title>";
echo " <description>" . $creator . "</description>";
echo " <media:content url="low/".$key.""></media:content>";
echo " <jwplayer:provider>rtmp</jwplayer:provider>";
echo " <jwplayer:streamer>rtmp://xxxx.id.xxxx.com/flash</jwplayer:streamer>";
echo " </item>";
}

echo " </channel>";
echo " </rss>";
}

?>

Reply
Reply

I've included the php scipt in the file now so you can see in the page source that it generates the xml as expected.

Reply

If you go to - http://www.thinqdifferently.com/code/includes/playlist-flv.php

It is blank.

The browser doesn't see it.

So neither will the player.

Reply

Thanks Nathan, moving the playlist file out of code/includes means it works. I'll go and have a look at the apache/php setup on this host.

Reply

As an aside this means that you can always see what is in the playlist. The server side include does provide the benefit of some obfuscation.

I need to think through how I can do this without exposing some of the mechanics of the way the videos are presented. I used to do this before by over-riding methods in the jwplayer actionscript, but now that I need to support html 5 thats not possible.

I'll update once I have had a think.

Reply

Ok, got it. Np.

Reply

Ethan, did some thinking and started to play with jwplayer().load instead. Initial phase but come across something that it would be good to get some feedback on.

Demo here http://www.thinqdifferently.com/playlistdemo.html

Core piece is this

onclick="jwplayer().load({levels: [ {file: 'low/filename.mov', streamer:'rtmp://fm-xxxxx.id.xxxx.com/flash', provider: 'rtmp' }, {file: 'http://download.xxxxx.com/bt/filename/data', provider: 'video'}, ]}).play()"

This works on Firefox and on Chrome but fails on iOS where it seems to be appending the hostname to the first option to get the following

http://www.thinqdifferently.com/low/filename.mov

am I missing something?

If I can get this working on iOS then I can move back to working on hiding the token generation and file name creation.

Reply

Also tried <a href="#" onclick="jwplayer().load({

modes: [ { type: 'flash', config: {file: 'low/filename.mov', streamer:'rtmp://fm-xxxxx.id.xxxx.com/flash', provider: 'rtmp' }}, { type: 'html5', config: {file: 'http://download.xxxxx.com/bt/filename/data', provider: 'video'}}, ]

}).play()">

but this only works for Firefox, Chrome plays the already loaded video again.

Reply

My mistake doesn't work in either

Reply

There could be a couple things going on here.

1) Mixing rtmp and progressive download in the levels block in your load command. If you just use the progressive download, does it work.

2) The progressive download not having a file extension.

Post new comment

  • Allowed HTML tags: <code> <blockquote> <em> <strong> <strike> <ul> <li> <ol>
  • You may post code using <code>...</code> .
  • Lines and paragraphs break automatically.
  • Web page addresses and e-mail addresses turn into links automatically.

More information about formatting options