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

Forums

/

Caching video while opening site but not playing

68 replies [Last post]

I think that a good option is to caching the video from time to loading the site, but not playing as "autostart".
Play would be started by visitors.
It is good for better quality of a video, visitors may start play after few seconds/minutes after loading a site.

How can I chech the code to make such solution.

michtec@wp.pl

i really need so :|

A simple solution would be to create a second swf and embed it in your page. Load the flv into it, and set the visibility of the the swf to hidden. That way, when someone gets to the page that contains your invisible swf, it will start loading the flv into it, but people will never see it. Once the loading is complete, the flv will go into the browser's cache, and be available for immediate loading into the flv player.

@Dean et al
that is indeed the only method of preloading videos, with the players at present, without modding.
it requires autostart to be set and volume to be off as well as the visibillity. the only problem being that it will just take bandwidth from other videos loading on anything but the fastest lines...

Hello,

Please check the site below:

http://www.pekabex.com.pl/upadlosc.php

and you need find link called:
"W telewizji WTK ukazuje się reportaż dotyczący Pekabex S.A."

There are flv wchich are loading on startup of viewing the site and not playing. The volume is about 50. Maybe the solution is in this that site is openning via javascrit?

my impression is that JeroenW has taken the decission not to implement preloading - i think a very early version of the player had preload, but that it was taken out because it was to heavy a load on bandwidth.
and also because it can be made as Dean outlines, or you can modify the player your self...
or you keep this thread alive and hope that JeroenW will make it an option ;)

Hello,

Youtube has preload and they are known with streaming video :)
I think that preload is needed with slow conection. It is the most importent with short and the best quality videos. If somebody want to see the 1 min film with the best quality he can be stressed without the preload. Instead the best quality has a braken many parts.

@Jonn et al
my impression is the opposite :) that on slow lines you should NOT use preload because of the heavy load - i agree with you that it is disturbing with the "chopping up" of the playing - what you can do is to set the flashvar bufferlenght - from the [url=http://www.jeroenwijering.com/extras/readme.html]readme[/url]:
"bufferlength (number): This sets the number of seconds an FLV should be buffered ahead before the player starts it. Set this smaller for fast connections or short videos. Set this bigger for slow connections. The default is 3 seconds."

I think that the site admin decides if to turn on or off this option. JeroenW should implement this option again and we decide to turn it on or off

and an other thing, some of my permlinks that i got from youripper changed after a week or so.. I don´t know why but for example the url
http://ash-v196.ash.youtube.com/get_video?video_id=mw_aFR1VaUM.flv changed to
http://chi-v196.chi.youtube.com/get_video?video_id=mw_aFR1VaUM.flv

@facundo,

See my post in this thread [url=http://www.jeroenwijering.com/?thread=4379]auto-preloading, without autoplay[/url] 20.05.2007 for a simple way to preload.

@John,

I don't think YouTube does either preload or streaming. From what I see they do a progressive download at maybe 110% of the video bandwidth rate to stay ahead of the player. Their video files always end up in my cache, so they aren't doing RTMP streaming.

Thanks will, but the thing is that I know too litle about programming. And I don´t know how to integrate your code into my web page: [url=http://www.cuarteto-cba.com.ar/tv/canales/canales.html]www.cuarteto-cba.com.ar/tv/canales/canales.htmlclick here[/url]
Do you have any hints for me?

@facundo,

Wait a little while, when I get home in 2-3 hours, I'll post modified code for you.

@facundo,

OK, I'm going to give you a bunch of things to do, step-by-step.  If you don't fully understand any of them, post back here and I'll clarigy them for you.

1) Change to using "swfobject.js" which is in the zip file with the flvplayer.  Put the file "swfobject.js" on your web server wherever "ufo.js" is now.

2) Change this line in your HTML

from:

<script type="text/javascript" src="ufo.js"></script>

to:

<script type="text/javascript" src="swfobject.js"></script>

3) Copy and paste the "additional.js" code below into a text editor, like notepad. Save it as "additional.js".  This file needs to go on your web server in the same directory where you put "swfobject.js" .

additional.js

// some variables to save
var currentPosition;
var currentVolume;
var currentItem;

// these functions are caught by the JavascriptView object of the player.
function sendEvent(typ,prm)
{
  thisMovie("mpl").sendEvent(typ,prm);
};

function getUpdate(typ,pr1,pr2,pid)
{
  if(typ == "time")
  {
    currentPosition = pr1;
  }
  else if(typ == "volume")
  {
    currentVolume = pr1;
  }
  else if(typ == "item")
  {
    currentItem = pr1; setTimeout("getItemData(currentItem)",100);
  }
  var id = document.getElementById(typ);
  id.innerHTML = typ+ ": "+Math.round(pr1);
  pr2 == undefined ? null: id.innerHTML += ", "+Math.round(pr2);
  if(pid != "null")
  {
    document.getElementById("pid").innerHTML = "(received from the player with id <i>"+pid+"</i>)";
  }
};

// These functions are caught by the feeder object of the player.
function loadFile(obj) { thisMovie("mpl").loadFile(obj); };
function addItem(obj,idx) { thisMovie("mpl").addItem(obj,idx); }
function removeItem(idx) { thisMovie("mpl").removeItem(idx); }
function getItemData(idx)
{
  var obj = thisMovie("mpl").itemData(idx);
  var nodes = "";
  for(var i in obj)
  { 
    nodes += "<li>"+i+": "+obj[i]+"</li>"; 
  }
  document.getElementById("data").innerHTML = nodes;
};

// This is a javascript handler for the player and is always needed.
function thisMovie(movieName)
{
  if(navigator.appName.indexOf("Microsoft") != -1)
  {
    return window[movieName];
  }
  else
  {
    return document[movieName];
  }
};

4) Add the code below to the <head> section of your HTML code, right below the code for "swfobject.js".

<script type="text/javascript" src="additional.js"></script>

5) In the <head> section of your HTML,

change this <script>:

  <script type="text/javascript">
    function createPlayer(filnam,varShuffle)
    { 
      var FO =
      {
                  movie:"mediaplayer.swf",
                  width:"600",
                 height:"430",
           majorversion:"8",
                  build:"0",
                bgcolor:"#FFFFFF",
        allowFullScreen:"true",  
              flashvars:""+'file='+filnam+'&
                         shuffle='+varShuffle+'&
                    displaywidth=600&
                   displayheight=410&
                            logo=http://img148.imageshack.us/img148/1377/logo3grandelr2.jpg&
                      showdigits=true&
                       showicons=false&
                       autostart=true&
                    bufferlength=10&
                          repeat=true&
                          volume=100&
                            link=http://www.cuarteto-cba.com.ar&
                     usecaptions=false&
                   usefullscreen=true&
                         usekeys=false&
                         showicons=true'+""
      }; 
      UFO.create(FO,"theMediaPlayer")
    }
  </script>

to this:

  <script type="text/javascript">
    function createPlayer(filnam, varShuffle)
    {
      var so = new SWFObject('mediaplayer.swf', 'mpl', '600', '430', '8');
        so.addVariable('backcolor', '0xFFFFFF');
        so.addVariable('file', '+filnam+');
        so.addVariable('shuffle', '+varShuffle+');
        so.addVariable('displaywidth', '600');
        so.addVariable('displayheight', '410');
        so.addVariable('logo', 'http://img148.imageshack.us/img148/1377/logo3grandelr2.jpg');
        so.addVariable('showdigits', 'true');
        so.addVariable('showicons', 'false');
        so.addVariable('autostart', 'true');
        so.addVariable('bufferlength', '10');
        so.addVariable('repeat', 'true');
        so.addVariable('volume', '100');
        so.addVariable('link', 'http://www.cuarteto-cba.com.ar');
        so.addVariable('usecaptions', 'true');
        so.addVariable('usefullscreen', 'true');
        so.addvariable('usekeys', 'false');
        so.addVariable('enablejs', 'true');
        so.addVariable('javascriptid', 'mpl');
        so.write('theMediaPlayer');
      var t = setTimeout("sendEvent('playpause')", 100);
    }
  </script>

You are my personal god will. I can belive that you took the time to give a step by step tutorial. I am really thanked to you. I will try this and give you my feedback

@facundo,

Just glad I could help. Plus there is a little secret here - I learned more than you did. And, it's satisfying to see someone's site working and knowing that I had a hand in that.

So, I hope you get it working and don't hesitate to post back here if you ned more help. The first time can be daunting.

Hi Guys...not sure, but think I may have the same problem. Trying to run multi-media playlist (2 x swf and 1 x mp3). The sound plays before the video.

Not sure what I'm doing....

Anyway, as my clients are mostly non computer types (50's plus...like me) would like it to play quickly/correctly when clicking a title from the playlist. No wait time.

Also get this message - "A script in this movie is causing Adobe Flash Player 9 to run slowly. If it continues to runyour computermay become unresponsive. Do you want to abort the script."

Site is www.c-dailyhealthjuice.com - please take a look and advise. Much appreciated.

P.S. Jeroen, do I owe a licence for this site?

@Derek,

Site at [url=http://www.c-dailyhealthjuice.com]www.c-dailyhealthjuice.com[/url] seems to be down?

Wll sorry for my late feedback, I´ve been studying a lot. Wll I have uploaded the files you told me and I have made the changes. But I don´t know what should I change on my <body> where it sais: <div id="theMediaPlayer"><a href="http://www.macromedia.com/go/getflashplayer">DescaRgA FlAsH</a> paRa PoDeR vEr La CuArTeTo-CbA Tv. </div>
Because I am Getting the "GET FLASH" text

@facundo,

Just one little typO in my code. :s

This line:

so.add<strong>V</strong>ariable('usekeys', 'false');

needs an uppercase 'V'.

Also, these two lines can be simplified from this:

so.addVariable('file', '+filnam+');
so.addVariable('shuffle', '+varShuffle+');

to this:

so.addVariable('file', filnam);
so.addVariable('shuffle', varShuffle);

Once those changes are made, your site works fine running on my server, so it shuld be good for you. :)

@facundo,

I was still getting one non-fatal JavaScript error so I removed this line of code from the bottom of the createPlayer() function. I don't recall the purpose of it, or if it was just left over from some copy/paste, but everything works without it and no more JavaScript errors!

So, remove or at least comment out "//" this line:

//var t = setTimeout("sendEvent('playpause')", 100);

Let me know how your site works once you have made these changes and be sure you post back here if you need some more help.

Yea! great work will! it´s wotkine fine now, but, it doesn´t seem to be preloading :s

sorry to make two post.

@Will

Take into account that the autostart var is true. But when I make it false (to check the preloading). It just won´t load

Oh, that's why we had that var t...

Ok, let me review what we were trying to do and we will get your preloading working also.

Yes I guessed that that was the reason but I tryied with and without that code line, but it didn´t worked. Thanks for your time will, post when you get time

@facundo,

One of the last problems is that you are using an old version of the player (3.6) which does not respond to all of the JavaScript commands.

Please upgrade to the latest player from Jeroen's site.

Your code works perfectly in the Opera browser with the v3.8 player, for some reason, Internet Explorer does not like the setTimeout() command. I will track that down tomorrow.

Oh, my bad then, I thought I had the last version, sorry. I will upgradeit and wait for the IE problem to get solved, because, besides I use Firefox, my web page is intended to be for everyone, so I hope you can find the problem will, and I think I´ll never stop thanking you... thanks again

@facundo,

Three more things for you to fix.

1. You need to use the latest "swfobject.js" file. It shuld be in the player package you downloaded. Everytime you upgrade the player, make sure you upgrade "swfobject.js".

2. All of your playlists MUST have this line as the very first line:

<?xml version="1.0" encoding="UTF-8"?>

3. What are you using to generate the playlists, because this one has some problems near the end:

ewoiuasdjflkfvcnsd456dsyou.xml

You might want to give all of them a quick check.

I'm still working on the setTimeout() problem, meanwhile you can fix these other items.

3. What are you using to generate the playlists, because this one has some problems near the end.

My keyboard :p lol
You can say that it´s done by hand (because I am having problems with this: http://www.jeroenwijering.com/?thread=4230#msg25407)
I´ll check them but, as far as I know, there are no problem with them. The only "problem" I think it´s that some links include a "?" and xml doesn´t seem to like that, but they work fine thow.
I dont understand what´s the "encoding="UTF-8" for? but I´ll added.

And the problem regarding the "swfobject.js" (again) I thought I had updated it, but I´ll upload it again as well

@facundo,

That's too bad that you have to generate your playlists manually. I'll look around to see if there is any other way to access remote files when your host has file access and curl disabled.

For your main page, the problem with the player not pausing during preloading in Internet Explorer turned out to be caused by the whole page, including the flash player, being enclosed in <form>...</form> tags.

For unknown reasons, and others on these forums have reported the same problem, the Flash player doesn't work too well within a form.

Anyway, I have a verson of your page that works, you can download it from this link [url=http://67.101.53.210:8085/downloads/facundo.txt]facundo.txt[/url]. Change the file extension to html and try it.

Right now, the delay before the player pauses is set at 3,000 milliseconds. You might want to set it to a lower value depending on how much of the video you want displayed before the player pauses. Exactly what has happened on the client computer (player load, playlist load, video load) by the end of that time delay is going to depend on the client computer speed, bandwidth, and delay at the video provider. If you set it too low, the player may not have loaded completely and then the pause won't happen. Probably 300-500 milliseconds is OK. Just change this line.

var t = setTimeout("sendEvent('playpause')", 3000);

I have updated my code (http://www.cuarteto-cba.com.ar/tv/canales/index.html) but still doesn´t preload on firefox, and i can´t get the player to load on IE :s

@facundo,

I checked your site with the new code.

Here's what I found.

1. You have changed these two lines from this:

<script type="text/javascript" src="swfobject.js"></script>
<script type="text/javascript" src="additional.js"></script>

To this:

<script type="text/javascript" src="http://www.cuarteto-cba.com.ar/playlist/swfobject.js"></script>
<script type="text/javascript" src="http://www.cuarteto-cba.com.ar/playlist/additional.js"></script>

That is not going to work. JavaScript security "sandboxing" requires files to come from the same place. Put those two JavaScript files with your player.swf and playlist(s).xml and things will work.

2. You have changed this line from this:

so.addVariable('autostart', '<strong>true</strong>');

To this:

so.addVariable('autostart', '<strong>false</strong>');

We need to have autostart on ('true') to start the preloading, then the timed call to 'playpause' will pause the player while preloading continues.

After I changed those two items, your page loads, starts preloading, and pauses while the preload continues. I tested in Internet Explorer and Opera. I don't have FireFox, so I can't test in that.

One other thing to check is the version of the Flash plugin that you have in both of your browsers. The required version is Flash 9 although I set it to 7 for testing. Eventually, this line should be changed from this:

var so = new SWFObject('mediaplayer.swf', 'mpl', '600', '430', '<strong>7</strong>');

To this:

var so = new SWFObject('mediaplayer.swf', 'mpl', '600', '430', '<strong>9</strong>');

to alert your users to update their Flash plugin.

THANKS WILL!!!!!!!
Well I found the problem, the problem was the settimeout var. It was too small I had to put 3000. With 500 wasn´t working at all, neither with 1000.
Thanks for all your time.

Ps: check my source code and you will see that there is no problem with this line
<script type="text/javascript" src="http://www.cuarteto-cba.com.ar/playlist/swfobject.js"></script>
The players is finally working!! Yeah

!!!YEAH!!! from me too.

Hey, if a full URL works for you, it works for me too.

Now, just be very careful about making changes. Make one at a time and test it for a while on all of the different browsers and get some users to test for you also. Surprises are not pleasant in this business.

Nice "lively" music in those videos.

Good Luck... :) and time for (b)

Now, just be very careful about making changes. Make one at a time and test it for a while on all of the different browsers and get some users to test for you also

Yes I know, I´ll be careful

Nice "lively" music in those videos.

lol, this music is like rap. What I mean is that this music is listened by the same kind of people (in my city) as rap (in US). I just like some of them.

Good Luck... smiley and time for beer

If you were from Argentina (my country) I would buy you a beer, but I guess you are not :p
See you will and thanks for all the trouble

facundo,

One thing I thought of for your playlists is that you can run PHP on your computer to generate the playlists, then all you have to do is upload them. That would save yu a lot of work, because those links to the FLVs are going to change frequently and maintenance of your playlists will be a lot of work.

Just download the PHP package from here [url=http://www.php.net/downloads.php]PHP Downloads[/url], run the installer, then call the PHP interpreter from the command line like this:

PHP playlist_generator.php?filename=urls.txt >playlist.xml

Thanks will I tryied it and I got the following problems:
1- I had to change this line:
PHP playlist_generator.php?filename=urls.txt >playlist.xml
to this one
PHP playlist_generator.php? filename=urls.txt >playlist.xml

2- My output file is this one:

<?xml version='1.0' encoding='UTF-8'?>
<playlist version='1' xmlns='http://xspf.org/ns/0/'>
  <trackList>
    <track>
      <title></title>
      <creator></creator>
      <location></location>
      <meta rel='type'>flv</meta>
      <image></image>
      <info>http://www.cuarteto-cba.com.ar</info>
    </track>
  </trackList>
</playlist>

and my urls.txt is this one:

http://youtube.com/watch?v=fcy8QcS21PA

Don´t know which could be the problem.

I have copied this files to the "php-5.2.3" installation path:
HTTP.php
urls.txt
playlist_generator.php

I don´t know if I´m missing something

@facundo

The HTML page changed slightly.

Find this line in "youtube_playlist.php"
[code}
if (preg_match('/\/player2\.swf\?video_id=.*?&t=(.*?)"/', $html, $match))

and change it to this:

if (preg_match('/\/player2\.swf\?hl=en&BASE_YT_URL=http:\/\/youtube.com\/&video_id=.*?&t=(.*?)&/', $html, $match))

Your command line should be:

php youtube_playlist.php filename=urls.txt > playlist.xml

I see you already figured that out.

Be sure that you are using "youtube_playlist.php"

Doesn´t the playlist generator like my songs?? :s
I tryied with the urls.txt file that came with the generator and all worked right, but when I tryied with MY links:
http://www.youtube.com/watch?v=J3MHkKWP1hQ
http://www.youtube.com/watch?v=RsNKEzRYUG4
http://www.youtube.com/watch?v=3OEfAwYcDnw

I got the following:

<?xml version='1.0' encoding='UTF-8'?>
<playlist version='1' xmlns='http://xspf.org/ns/0/'>
<trackList>
<track>
<title></title>
<creator></creator>
<location></location>
<meta rel='type'>flv</meta>
<image></image>
<info>http://www.cuarteto-cba.com.ar</info>
</track>
...

Maybe the playlist generator doesn´t like my songs.. lol but I know that the programm is working (after the changes) because it worked fine with the othe "urls.txt"

@facundo,

I'll update the script to handle "youtube.com" or "www.youtube.com".

D:\PHP\php-5.2.0-Win32>php youtube_playlist.php filename=urls.txt > playlist.xml

urls.txt
http://youtube.com/watch?v=J3MHkKWP1hQ
http://youtube.com/watch?v=RsNKEzRYUG4
http://youtube.com/watch?v=3OEfAwYcDnw
http://youtube.com/watch?v=fcy8QcS21PA
Note: NO www[b/]

playlist.xml

<?xml version='1.0' encoding='UTF-8'?>
<playlist version='1' xmlns='http://xspf.org/ns/0/'>
  <trackList>
    <track>
      <title>Damian Cordoba - 08 - Yo Quiero Tenerla</title>
      <creator>Cuartetocba</creator>
      <location>http://ash-v159.ash.youtube.com/get_video?video_id=J3MHkKWP1hQ</location>
      <meta rel='type'>flv</meta>
      <image>http://img.youtube.com/vi/J3MHkKWP1hQ/2.jpg</image>
      <info>http://my.domain.com</info>
    </track>
    <track>
      <title>Damian Cordoba - 10 - Eres</title>
      <creator>Cuartetocba</creator>
      <location>http://sjl-v87.sjl.youtube.com/get_video?video_id=RsNKEzRYUG4</location>
      <meta rel='type'>flv</meta>
      <image>http://img.youtube.com/vi/RsNKEzRYUG4/2.jpg</image>
      <info>http://my.domain.com</info>
    </track>
    <track>
      <title>Damian Cordoba - 09 - Jugaste</title>
      <creator>Cuartetocba</creator>
      <location>http://ash-v7.ash.youtube.com/get_video?video_id=3OEfAwYcDnw</location>
      <meta rel='type'>flv</meta>
      <image>http://img.youtube.com/vi/3OEfAwYcDnw/2.jpg</image>
      <info>http://my.domain.com</info>
    </track>
    <track>
      <title>The Many Faces of MaryAnne a.k.a. Ysabellabrave</title>
      <creator>OkieDokiePookie</creator>
      <location>http://lax-v206.lax.youtube.com/get_video?video_id=fcy8QcS21PA</location>
      <meta rel='type'>flv</meta>
      <image>http://img.youtube.com/vi/fcy8QcS21PA/2.jpg</image>
      <info>http://my.domain.com</info>
    </track>
  </trackList>
</playlist>

@facundo

Find this line:

$entry = rtrim($entry);

and add this line after it:

$entry = str_replace("www.", "", $entry);

@Will since I´ve became your beta tester here is my feedback :p :
1} If I remove the www. from the playlist adesses it works GREAT
2} if I change the line that you said, {even if I´ve removed or not the www.} the playlist will be:

      ......
      <track>
      <title></title>
      <creator></creator>
      <location></location>
      <meta rel='type'>flv</meta>
      <image></image>
      <info>http://www.cuarteto-cba.com.ar</info>
    </track>
    <track>
      <title>Damian Cordoba - 02 - Como Una Puñalada</title>
      <creator>Cuartetocba</creator>
      <location>http://ash-v153.ash.youtube.com/get_video?video_id=VVdfM7Ha0ek</location>
      <meta rel='type'>flv</meta>
      <image>http://img.youtube.com/vi/VVdfM7Ha0ek/2.jpg</image>
      <info>http://www.cuarteto-cba.com.ar</info>
    </track>
  </trackList>
</playlist>

Only the last video info is displayed

There is no need that you change your code again for me {I´ll just remove the www.}
But if you want to to change the code I can test it for you. Is the least I can do for you

@facundo,

Also, since you are now running in CLI mode, only the default file "urls.txt" is being used.

Find this near the top of the script:

if ($_REQUEST['filename'])
{
  $filename = $_REQUEST['filename'];
}
else
{
  $filename = "urls.txt";
}

and replace it with this:

if ($_REQUEST['filename'])
{
  $filename = $_REQUEST['filename'];
}
else
{
  if ($argv[1])
  {
    parse_str($argv[1]);
  }
  else
  {
    $filename = "urls.txt";
  }
}

That will let you name your URL files anything you want, like:
rythm_blues_urls.txt
salsa_urls.txt
hot_chicks_urls.txt

@facundo,

Just saw your post about the www thing not working.

I'll check it and post a fix ASAP.

@facundo,

Did you add or replace that line for the "www". Mine is OK.

You should have two lines of code, like this:

$entry = rtrim($entry);
$entry = str_replace("www.", "", $entry);

Sorry I replaced it, when I added the other line it worked.
I don´t understand what´s the other change for?

I can change this
php youtube_playlist.php filename=urls.txt > playlist.xml
to this?:
php youtube_playlist.php filename=*.txt > playlist.xml
(where *=anyname)

Or it will automatically detect my *.txt file in the dir? if so, what happens if I have two *.txt files? Is it possible a multiplaylist creator?
urls.txt->urls.xml
urls2.txt->urls2.xml

Thanks will and if you want I can suggest you some changes/improvements for your aplication. You can also contact Jeroen so he adds you "plugin" to the main page. It´s very usefull
Ps: Great Job!

The other change is so that you can have multiple URL files. Each one will have to be processed individually like this:

php youtube_playlist.php filename=salsa_urls.txt > playlist_salsa.xml
php youtube_playlist.php filename=rock_urls.txt > playlist_rock.xml
php youtube_playlist.php filename=blues_urls.txt > playlist_blues.xml

Without that change, the playlist generator will always default to the "urls.txt" file.

Thanks for being a beta tester. Many other flash player users are restricted by their hosting companies from accessing external files from the server, so they can use this same method for making playlists.

I always welcome any suggestions for my applications. That is how they get better, and better. Thanks for your help.

I can make it into a mylti-playlist creator if that would be useful to you. It would find all .txt files and process them to make playlists with the same name.

So:
rock.txt => rock.xml
blues.txt => blues.xml
salsa.txt => salsa.xml

It's easy to do. Would that be useful to you?

Yes It would be useful but I don´t want to take more of your time that I have already taken. I can run the php a few times to creat all of my playlist, don´t worry. I was asking just in case you were interested in making it a more complete (automated) aplication.
If you are willing to do it I can "help" you with some ideas or with some testings

Facundo,

Yes, please send me your ideas, because I want to continue development of the playlist generators.

Ok the *.txt file detection is one improvement. Here are some options:
1- Read all the *.txt files and generate the *.xml files
2- Read all the [string]*.txt and generate the [string]*.xml files
For example, music_playlist1.txt, music_soft.txt, musicheavyrock.txt.
And [string] in this case is "music" but it´s a prefix that we can change from the php file. Is [string] is blank then it will process all the *.txt files.
If I get any more ideas I´ll post them here

@facundo,

OK, here is a playlist generator for you to test. [url=http://68.164.132.108:8085/downloads/YT_playlist_test.zip]YT_playlist_test.zip[url]

Here's how it works:

1. If called from a browser with no filename, it defaults to "urls.txt" in the same directory and returns a playlist to the browser.
http://my.domain.com/path-to-file/youtube_playlist_debug.php

2. If called from a browser with a filename (can include a subdirectory), it returns a playlist to the browser.
http://my.domain.com/path-to-file/youtube_playlist_debug.php?filename=urls.txt
http://my.domain.com/path-to-file/youtube_playlist_debug.php?filename=music/urls.txt

3. If called from a browser with a subdirectory or a complete drive path, it parses every file with an extension of ".txt". If it finds lines that begin with "http://" it assumes that they are valid URLs and they are processed. Multiple playlist files will be returned to the browser.
http://my.domain.com/path-to-file/youtube_playlist_debug.php?filename=. (use a period for the current directory)
http://my.domain.com/path-to-file/youtube_playlist_debug.php?filename=music (if music is a subdirectory, it will be parsed for files with extensions of ".txt" and they will be processed.)

4. If called from the command line with no filename, it defaults to "urls.txt" and writes a playlist to "urls.xml".
php youtube_playlist_debug.php

5. If called from the command line with a filename (can include a subdirectory), it writes a playlist to that filename (including the subdirectory) with ".xml" appended to the filename.
php youtube_playlist_debug.php filename=rock.txt (results in a playlist named "rock.xml")
php youtube_playlist_debug.php filename=music/rock.txt (results in a playlist named "music/rock.xml")

6. If called from the command line with a subdirectory or a complete drive path, it parses every file with an extension of ".txt". If it finds lines that begin with "http://" it assumes that they are valid URLs and they are processed. Multiple playlist files will be written with ".xml" appended to the filename.
php youtube_playlist_debug.php filename=. (use a period for the current directory)
php youtube_playlist_debug.php filename=music (if music is a subdirectory, it will be parsed for files with extensions of ".txt" and they will be processed.)

In all cases, the files are parsed for lines that begin with "http://", which are assumed to be valid URLs. If the URL doesn't return a URL to a video file, it is dropped from the array so there aren't any blank tracks in the playlist.

I need to think a little about your [string] suggestion, maybe a new version tomorrow.

Thanks will I´ll try it (from the command line) and give you a feedback. Grat job

I tryied number 4 and 5.
I can´t get number 6 to work

...
php youtube_playlist_debug.php filename=. (use a period for the current directory)

I don´t understand what´s this for.. the php will search the actual folder for txt files?

php youtube_playlist_debug.php filename=music (if music is a subdirectory, it will be parsed for files with extensions of ".txt" and they will be processed.)

This is not working for me... when I try:
php youtube_playlist_debug.php filename=playlist
where playlist is my directory. The playlist aren´t generated.

Ps: I check if it was case sensytive and it´s not, that´s a good thing

Ok I figured it out.
It was like I thought:
php youtube_playlist_debug.php filename=. (use a period for the current directory)
the php will search the actual folder for txt files.

And in orther to search an other folder I had to add /.
Like this:
php youtube_playlist_debug.php filename=playlist/.

Then I tryed some other playlists, for example this one:

http://youtube.com/watch?v=sNazS7WXvVQ
http://cuarteto-cba.com.ar

Generates this:

<?xml version='1.0' encoding='UTF-8'?>
<playlist version='1' xmlns='http://xspf.org/ns/0/'>
  <trackList>
  </trackList>
</playlist>

This one is not processed:

htttp://cuarteto-cba.com.ar
http://www.youtube.com/watch?v=gUd9nNPnaQg

Nor this one:

facundo
http://www.youtube.com/watch?v=nA80yfNaMNI

@facundo,

Thanks for testing for me.

To search another folder, all you need is the folder name, no trailing slash.
Like this:

php youtube_playlist_debug.php filename=playlist

if the folder is a subdirectory of the current folder (where you are executing PHP from).

You can also use a full path from the drive root:

php youtube_playlist_debug.php filename=/music/facundo/playlist

Be aware that any path that you use will also be used in the playlist, which may not be exactly what you want.

If you have a playlist URLs txt file that doesn't have any valid URLs, there should not be any playlist generated. If there are some valid, and some invalid URLs, the invalid URLs will be skipped so there are not empty tracks.

Thanks for the feedback. I will test those URLs that you posted and fix the playlist generator.

To search another folder, all you need is the folder name, no trailing slash.
Like this:

php youtube_playlist_debug.php filename=playlist

Yes but that is not working.. at least not working for me.
The php soft is here:
E:\Pagina Mia\youtube\php
my playlist are here:
E:\Pagina Mia\youtube\php\playlist

In the command line I enter this:
E:\Pagina Mia\youtube\php> php youtube_playlist_debug.php filename=playlist
But that doesn´t work (is it working for you?), this one works fine
E:\Pagina Mia\youtube\php> php youtube_playlist_debug.php filename=playlist/.

This line:

E:\Pagina Mia\youtube\php> php youtube_playlist_debug.php filename=playlist

works for me.

I'll take another look at the code just to be sure.

I also fixed those other examles that you posted. As soon as I have fully tested all of the browser and command line methods, I'll post the new code for you to test.

Thanks again for your test results. :)

Check out anderson's post of 13.06.2007 in this thread [url=http://www.jeroenwijering.com/?thread=5586]loadFile and Play[/url]. He has posted a small JavaScript function to check if the player is ready before playing. You could use that instead of the long time delay that you have now. Then if the player was ready earlier, it would pause.

Thanks will I´ll take a look at the post and I´ll be waiting for the fixed version to test

Well Will you Playlist generator is really useful, and the option to process a hole directory GREAT.
Thanks a lot also to jeroen GREAT player too
Hope you guys keep your good job.
Freeware is the BEST software

Will I got some problems:
http://img120.imageshack.us/img120/4584/playlistic6.jpg

First of all, I can no longer create the playlist for a full directory, i don´t know why...
and when I was trying to create the playlist for the file rodrigo.txt i got that error

rodrigo.txt´s content:

http://www.youtube.com/watch?v=sNazS7WXvVQ

Changes at YouTube...

Try this [url=http://67.101.52.244:8085/downloads/YT_playlist_test.zip]YT_playlist_test.zip[/url]

Yes youtube $%#"%#"% :@ It´s changing everything! and I´ll have to change everything as well!
I´ll try it will thanks

It´s working great Will now this line:
E:\Pagina Mia\youtube\php> php youtube_playlist_debug.php filename=playlist
(where playlist is my directory)
Is working for me too.

Btw I don´t know if you forgot but you left this function

function debug($text1, $text2)
{
print "<pre>\n";
print $text1 . $text2 . "\n";
print "</pre>\n";
}

and is printing everything, lol, now I can see internals :p
just for you to know.
Oh, I am also using your statistics.php now :)

@facundo,

You are using the debug version. You can turn on/off the debugging by uncommenting/commenting any debug(); statements throughout the code.

Good it's working, expect it to break as Google/YouTube continue to merge. Google video feeds now have some YouTube links in them.

@facundo,

Are you using the version of statistics.php that creates an Apache format log file?

If so, have you looked at [url=http://www.hping.org/visitors/]Visitors[/url].

Here is the output of Visitors from my statistics.log (mostly faked for testing) [url=http://67.101.52.244:8085/visitors-flvplayer-report.html]statistics.log analyzed by Visitors[/url]

Hi,
I have a requirement to load a new video *.avi file every few seconds. The problem is that the file name will be same as the previous one.. As an example, I will have a video.avi file onto the server which will be downlaoded onto an embedded media player. After a few seconds this file on the server will be replaced by a newer video.avi file and the player needs to play the new file. Instead i see that the player just replays the previous file, which possibly is present in the temperory files. I have tried disabling the browser caching but it does not work for the media player. Even if hte file is deleted from the server, the browser keeps playing it. INstead i need the browser's player to read the file every time before playing it and that too not from the local cache but from the browser. Bandwidth is not at all an issue.

Any pointers???