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

External playlist links + xmoov + JW Player 4.2.80

10 replies [Last post]

Hello!

Firstly, sorry for my terrible English, I hope it will be understandable.

I've created a simple player code with external html playlist links ( my original source was an example code from http://home5.inet.tele.dk/nyboe/flash/mediaplayer/ ).

Recipe:
- The sample code
- JW Player 4.2.80
- newest xmoov.php

My player: http://paleee.hu/btv/01/teszt.php

If you click from file to file, Firefox randomly freezes. Once it freezes at the first click, but sometimes it freezes after 2-3 different clicks.

If I disable the xmoov.php line, it works perfectly. So what do I wrong?

Thank you, If someone could help me!

My code:

<html>
<head>
<title>On-Demand TV</title>

<script type="text/javascript" src="http://paleee.hu/btv/01/../addins/swfobject.js"></script>
<script type="text/javascript">

function createplayer(theFile, go) {
var so = new SWFObject("http://paleee.hu/btv/01/../addins/player.swf","playerID","400","245","7");
  so.addParam('allowfullscreen','true');
  so.addParam('allowscriptaccess','always');
  so.addParam('wmode','opaque');
  so.addVariable('streamer','http://paleee.hu/btv/01/../addins/xmoov.php');
  so.addVariable('file',theFile);
  if (go) { so.addVariable("autostart","true"); }
    so.write("placeholder");

}
</script>

</head>
<body onLoad="createplayer('8terra.flv', true)">


Test code, but not working...<br>
<br>
<a href="javascript:createplayer('001.flv', true)">001.flv</a><br>
<a href="javascript:createplayer('003.flv', true)">003.flv</a><br>
<a href="javascript:createplayer('video.flv', true)">video.flv</a><br>
<div id="placeholder"><a href='http://www.macromedia.com/go/getflashplayer'>get the flash player</a> to see this player.</div>

</body>
</html>

My xmoov.php:

<?
    /*
   
        xmoov-php 0.9
        Development version 0.9.3 beta
       
        by: Eric Lorenzo Benjamin jr. webmaster (AT) xmoov (DOT) com
        originally inspired by Stefan Richter at flashcomguru.com
        bandwidth limiting by Terry streamingflvcom (AT) dedicatedmanagers (DOT) com
       
        This work is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License.
        For more information, visit http://creativecommons.org/licenses/by-nc-sa/3.0/
        For the full license, visit http://creativecommons.org/licenses/by-nc-sa/3.0/legalcode
        or send a letter to Creative Commons, 543 Howard Street, 5th Floor, San Francisco, California, 94105, USA.
       
       
    */

   
    //    SCRIPT CONFIGURATION
  
    //------------------------------------------------------------------------------------------
    //    MEDIA PATH
    //
    //    you can configure these settings to point to video files outside the public html folder.
    //------------------------------------------------------------------------------------------
   
    // points to server root
    define('XMOOV_PATH_ROOT', 'd:/www/paleee/');
   
    // points to the folder containing the video files.
    define('XMOOV_PATH_FILES', '/btv/01/');
   
   
   
    //------------------------------------------------------------------------------------------
    //    SCRIPT BEHAVIOR
    //------------------------------------------------------------------------------------------
   
    //set to TRUE to use bandwidth limiting.
    define('XMOOV_CONF_LIMIT_BANDWIDTH', TRUE);
   
    //set to FALSE to prohibit caching of video files.
    define('XMOOV_CONF_ALLOW_FILE_CACHE', TRUE);
   
   
   
    //------------------------------------------------------------------------------------------
    //    BANDWIDTH SETTINGS
    //
    //    these settings are only needed when using bandwidth limiting.
    //   
    //    bandwidth is limited my sending a limited amount of video data(XMOOV_BW_PACKET_SIZE),
    //    in specified time intervals(XMOOV_BW_PACKET_INTERVAL).
    //    avoid time intervals over 1.5 seconds for best results.
    //   
    //    you can also control bandwidth limiting via http command using your video player.
    //    the function getBandwidthLimit($part) holds three preconfigured presets(low, mid, high),
    //    which can be changed to meet your needs
    //------------------------------------------------------------------------------------------   
   
    //set how many kilobytes will be sent per time interval
    define('XMOOV_BW_PACKET_SIZE', 90);
   
    //set the time interval in which data packets will be sent in seconds.
    define('XMOOV_BW_PACKET_INTERVAL', 0.3);
   
    //set to TRUE to control bandwidth externally via http.
    define('XMOOV_CONF_ALLOW_DYNAMIC_BANDWIDTH', FALSE);
   
   
   
    //------------------------------------------------------------------------------------------
    //    DYNAMIC BANDWIDTH CONTROL
    //------------------------------------------------------------------------------------------
   
    function getBandwidthLimit($part)
    {
        switch($part)
        {
            case 'interval' :
                switch($_GET[XMOOV_GET_BANDWIDTH])
                {
                    case 'low' :
                        return 0.5;
                    break;
                    case 'mid' :
                        return 0.5;
                    break;
                    case 'high' :
                        return 0.2;
                    break;
                    case 'off' :
                        return 0;
                    break;
                    default :
                        return XMOOV_BW_PACKET_INTERVAL;
                    break;
                }
            break;
            case 'size' :
                switch($_GET[XMOOV_GET_BANDWIDTH])
                {
                    case 'low' :
                        return 20;
                    break;
                    case 'mid' :
                        return 40;
                    break;
                    case 'high' :
                        return 90;
                    break;
                    default :
                        return XMOOV_BW_PACKET_SIZE;
                    break;
                }
            break;
        }
    }
   
   
   
    //------------------------------------------------------------------------------------------
    //    INCOMING GET VARIABLES CONFIGURATION
    //   
    //    use these settings to configure how video files, seek position and bandwidth settings are accessed by your player
    //------------------------------------------------------------------------------------------
   
    define('XMOOV_GET_FILE', 'file');
    define('XMOOV_GET_POSITION', 'start');
    define('XMOOV_GET_AUTHENTICATION', 'key');
    define('XMOOV_GET_BANDWIDTH', 'bw');
   
   
   
    //    END SCRIPT CONFIGURATION - do not change anything beyond this point if you do not know what you are doing
   
   
   
    //------------------------------------------------------------------------------------------
    //    PROCESS FILE REQUEST
    //------------------------------------------------------------------------------------------
   
    if(isset($_GET[XMOOV_GET_FILE]) && isset($_GET[XMOOV_GET_POSITION]))
    {
        //    PROCESS VARIABLES
       
        # get seek position
        $seekPos = intval($_GET[XMOOV_GET_POSITION]);
        # get file name
        $fileName = htmlspecialchars($_GET[XMOOV_GET_FILE]);
        # assemble file path
        $file = XMOOV_PATH_ROOT . XMOOV_PATH_FILES . $fileName;
       
        # assemble packet interval
        $packet_interval = (XMOOV_CONF_ALLOW_DYNAMIC_BANDWIDTH && isset($_GET[XMOOV_GET_BANDWIDTH])) ? getBandwidthLimit('interval') : XMOOV_BW_PACKET_INTERVAL;
        # assemble packet size
        $packet_size = ((XMOOV_CONF_ALLOW_DYNAMIC_BANDWIDTH && isset($_GET[XMOOV_GET_BANDWIDTH])) ? getBandwidthLimit('size') : XMOOV_BW_PACKET_SIZE) * 1042;
       
        # security improved by by TRUI www.trui.net
        if (!file_exists($file))
        {
            print('<b>ERROR:</b> xmoov-php could not find (' . $fileName . ') please check your settings.');
            exit();
        }
        if(file_exists($file) && strrchr($fileName, '.') == '.flv' && strlen($fileName) > 2 && !eregi(basename($_SERVER['PHP_SELF']), $fileName) && ereg('^[^./][^/]*$', $fileName))
        {
            $fh = fopen($file, 'rb') or die ('<b>ERROR:</b> xmoov-php could not open (' . $fileName . ')');
               
            $fileSize = filesize($file) - (($seekPos > 0) ? $seekPos  + 1 : 0);
           
            //    SEND HEADERS
            if(!XMOOV_CONF_ALLOW_FILE_CACHE)
            {
                # prohibit caching (different methods for different clients)
                session_cache_limiter("nocache");
                header("Expires: Thu, 19 Nov 1981 08:52:00 GMT");
                header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
                header("Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0");
                header("Pragma: no-cache");
            }
           
            # content headers
            header("Content-Type: video/x-flv");
            header("Content-Disposition: attachment; filename=\"" . $fileName . "\"");
            header("Content-Length: " . $fileSize);
           
            # FLV file format header
            if($seekPos != 0)
            {
                print('FLV');
                print(pack('C', 1));
                print(pack('C', 1));
                print(pack('N', 9));
                print(pack('N', 9));
            }
           
            # seek to requested file position
            fseek($fh, $seekPos);
           
            # output file
            while(!feof($fh))
            {
                # use bandwidth limiting - by Terry
                if(XMOOV_CONF_LIMIT_BANDWIDTH && $packet_interval > 0)
                {
                    # get start time
                    list($usec, $sec) = explode(' ', microtime());
                    $time_start = ((float)$usec + (float)$sec);
                    # output packet
                    print(fread($fh, $packet_size));
                    # get end time
                    list($usec, $sec) = explode(' ', microtime());
                    $time_stop = ((float)$usec + (float)$sec);
                    # wait if output is slower than $packet_interval
                    $time_difference = $time_stop - $time_start;
                    if($time_difference < (float)$packet_interval)
                    {
                        usleep((float)$packet_interval * 1000000 - (float)$time_difference * 1000000);
                    }
                }
                else
                {
                    # output file without bandwidth limiting
                    print(fread($fh, filesize($file)));
                }
            }
           
        }
       
    }
?>

 
Get the xmoov script from this thread:
 
       http://www.jeroenwijering.com/?thread=13081

                it works!
 
                                                                                        :D

May I ask as to what that script actually does?

 
@Graxeon,

No, we don't answer those kinds of questions here! [Just kidding of course. :D]

Did you get the multiple locations per track working?

This script is used for "fake" streaming using the HTTP protocol with a serverside script which can be written in any scripting language that your server supports (PHP, JSP, ASP, VBS, and others).

The most fundamental, basic reason that people use this "fake" streaming is to be able to make a request to the server for a portion of the video starting at a keyframe. So if you want to scrub to the 30 minute point of a 120 minute movie, dragging the scrub bar to that point (about 1/4 of the way) will send a request to the server to seek into the file and start delivering the video file beginning near the 30 minute point. You can also programmatically send the seek request from JavaScript or the playlist.

This script also has bandwidth-limiting available.

If you have your own server or your host allows it, there are alternatives that work better.

Red5 is a RTMP (true streaming) server that is free, open-source and works well. It doesn't yet stream H.264 in the MP4 container (but will stream H.264 in the MP4 container soon).

LightTPD is a fast server that has mod_flv and mod_h264 streaming modules. It is free, open-source and works very well.

Commercially, there are FMS (Flash Media Server) and Wowza as well as streaming services like Bits on the Run (BotR) run by Jeroen himself.

That script is kind of pointless for me then xD

Thanks for the explanation...sorry I can't use it (hopefully someone else finds this and uses it, lol).

As for the multiple locations per track thing...I have 3 issues left (see the last post) :

http://www.jeroenwijering.com/?thread=13588

Here is a copy of it...but please reply in the other topic xD

It works great! Even the bug where the last location played when you went back to an older track is gone.

Only things I am wondering about now:

Why don't the creator tags work?
How can I change the track size? (if the creator tags aren't going to work, then I might as well make the track shorter)
And why isn't this working:

autostart: 'false'

It auto-starts even with that code =(

Thank you :D

Thank You kLink, with the mentioned xmoov.php it works great!

TY TY TY TY TY a million times!! :)

 
Excellent! Enjoy! :D

Paul:

Would you be so kind as to provide the url to your finished product? I'd love to see it.

Boots

Boots: here is the url:

http://paleee.hu/btv/01/index1.php

But it's not finished, because it doesn't work well :(
Now Firefox (and IE) stopped freezing, but there's another problem: the longer videos stops playing after ~2-4 minutes randomly. I don't know the reason, it just stops. It stops too after ~3 mins when you seek into the middle of a longer video and start watching it.

Any idea? Somebody mentioned me to use JW Player 3.x with xmoov. I think I'll go mad... :-D

ps: longer (> 3 min) videos are 001.flv ad get_video.flv

I am losing my mind on this TWO Weeks and I cannot figure it out..

I need some serious help and these forums do not have the answer. Can someone help me?

All I want to do is make the playlist in a separate area with the thumbnail, title, and description. I do not want it hooked into the movie. As far a slinking and what not I know how to do that. Its jsut making an external XML playlist load. I am gonna lose my mind. Please Help me

@Heem - please see the - http://www.jeroenwijering.com/?item=Javascript_API_Examples
and the example page - http://home5.inet.tele.dk/nyboe/flash/mediaplayer4
and find source code such as - http://home5.inet.tele.dk/nyboe/flash/mediaplayer4/JW_API_xmpl_1-1-1-4.html
or - http://home5.inet.tele.dk/nyboe/flash/mediaplayer4/custom_playlist.html

please note that the above examples all use the swfobjet v.2.1 - http://code.google.com/p/swfobject/

Post new comment

  • Allowed HTML tags: <code> <blockquote> <em> <strong> <strike> <ul> <li> <ol>
  • Lines and paragraphs break automatically.
  • You may post code using <code>...</code> (generic).

More information about formatting options