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

Forums

/

Getting Dailymotion To Play In JW PLAYER

14 replies [Last post]

i am trying to make a plugin that would play a video From Dailymotion inside of the JW PLAYER.. And i having an issues that is driving me crazy...

so maybe someone with more knowledge can help me out here.. the plugin is pretty simple and is for a joomla video component. so i will post the revelant part of the php code..

basically i am grabbing the load a VIDEO LINK from the DAILYMOTION that located in my DB

so the $video_detail->video_url = http://www.dailymotion.com/video/x4m1b6_sengoku-kazuyuki-fujita-vs-peter-gr_sport

then i am using CURL to load the link above over at http://www.keepvid.com and then it will SCRAPE the source code of the page for the .FLV link which everything working fine. as i scrape and extract the .flv file link from keepvid and you can download the video.. and also i echoed the link to my page no problem..

<?php

// ##################################################
// ########### GET DIRECT FLV LINK FROM DAILYMOTION
// ##################################################

       

$geturl = "http://keepvid.com/?url=".$video_detail->video_url."";
       
//$geturl = $video_detail->video_url; // RETRIEVE video_url FROM THE DATABASE
   
       
if (function_exists('curl_init')){
           
$ch=curl_init();
           
$timeout=30; // set to zero for no timeout
           
curl_setopt($ch,CURLOPT_URL, $geturl);
           
curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
           
curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,$timeout);
           
$file_contents=curl_exec($ch);
           
curl_close($ch);
        }

       

$start_position = strpos($file_contents, "Links found on");
       
$start_position = strpos($file_contents, "Report any problems to", $start_position);
       
$start_position = strpos($file_contents, "<a href=\"", $start_position)+9;
       
$end_position = strpos($file_contents, "\"", $start_position)-$start_position;
       
$getflvlink = substr($file_contents, $start_position, $end_position);
       
$flv_link = ltrim($getflvlink);
//        echo "".$flv_link."";

// $flv_link = "http://proxy-35.dailymotion.com/16/320x240/flv/7746594.flv?3729391860564098ca7ed38576d57c4e13a7dae";

?>

    <script type="text/javascript">
      var flashvars =
      {
        'file':                                  '<?php echo $flv_link;?>',
        'type':                                  'video',
'skin': '<?php echo $mosConfig_live_site;?>/components/com_jomtube/assets/swf/skins/bekle/overlay.swf',
'controlbar': 'over',
        'stretching':                            'uniform',
        'frontcolor':                            'ffffff',
        'lightcolor':                            'ff6600',
        'autostart':                             'true'
      };

      var params =
      {
        'allowfullscreen':                       'true',
        'allowscriptaccess':                     'always'
      };

      var attributes =
      {
        'name':                                  'JomPlayerId1',
        'id':                                    'JomPlayerId1'
      };

      swfobject.embedSWF('<?php echo $mosConfig_live_site;?>/components/com_jomtube/assets/swf/player.swf', 'JomTubePlayerId1', '<?php echo $videowidth;?>', '<?php echo $videoheight;?>', '9.0.124', false, flashvars, params, attributes);
    </script>

<?php

        $jwplayer_embed = "<div id=\"JomPlayerContainer\" class=\"JomPlayerContainer\">
                              <a id=\"JomTubePlayerId1\" class=\"player1\" href=\"http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash\">Get the Adobe Flash Player to see this video.</a>
                          </div>
                          "
;
        return
$jwplayer_embed;

?>

and this is the part thats driving me crazy... is run the php it returns on the page..

Get the Adobe Flash Player to see this video.

but if i uncomment the hardcoded variable then it works

// $flv_link = "http://proxy-35.dailymotion.com/16/320x240/flv/7746594.flv?3729391860564098ca7ed38576d57c4e13a7dae";

or if hard code the in javascript

'file': 'http://proxy-35.dailymotion.com/16/320x240/flv/7746594.flv?3729391860564098ca7ed38576d57c4e13a7dae',

instead

'file': '<?php echo $flv_link;?>',

i just dont understand as i can echo the exact same link on the same page that i WEBSCRAPED from the the http://www.keepvid.com but instead of the jwplayer showing the video it shows the Get the Adobe Flash Player to see this video. but if i uncomment the the 2 methods above with same exact link and hard code it in the php it works..

any help appreciated.. as i run out of logical ideas..

This works for me. I would work backwards from this, gradually replacing the hard-coded elements with your variable elments until it breaks, then figure out why it breaks on that element.

<?php

// ##################################################
// ########### GET DIRECT FLV LINK FROM DAILYMOTION
// ##################################################

/*
$geturl = "http://keepvid.com/?url=".$video_detail->video_url."";
//$geturl = $video_detail->video_url; // RETRIEVE video_url FROM THE DATABASE

if (function_exists('curl_init')){
$ch=curl_init();
$timeout=30; // set to zero for no timeout
curl_setopt($ch,CURLOPT_URL, $geturl);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,$timeout);
$file_contents=curl_exec($ch);
curl_close($ch);
}

$start_position = strpos($file_contents, "Links found on");
$start_position = strpos($file_contents, "Report any problems to", $start_position);
$start_position = strpos($file_contents, "<a href=\"", $start_position)+9;
$end_position = strpos($file_contents, "\"", $start_position)-$start_position;
$getflvlink = substr($file_contents, $start_position, $end_position);
$flv_link = ltrim($getflvlink);
// echo "".$flv_link."";

*/

$flv_link = "http://proxy-35.dailymotion.com/16/320x240/flv/7746594.flv?3729391860564098ca7ed38576d57c4e13a7dae";
?>

<html>

  <head>

    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/swfobject/2.1/swfobject.js"></script>

    <script type="text/javascript">
      var flashvars =
      {
        'file':                     '<?php echo $flv_link;?>',
        'type':                     'video',
        'skin':                     'bright',
        'controlbar':               'over',
        'stretching':               'uniform',
        'frontcolor':               'FFFFFF',
        'lightcolor':               'FF6600',
        'autostart':                'true'
      };

      var params =
      {
        'allowfullscreen':          'true',
        'allowscriptaccess':        'always'
      };

      var attributes =
      { 
        'name':                     'JomPlayerId1',
        'id':                       'JomPlayerId1'
      };

      swfobject.embedSWF('player-4.4.162.swf', 'JomTubePlayerId1', '640', '500', '9.0.124', false, flashvars, params, attributes);
    </script>

  </head>

  </body>

    <div id="JomPlayerContainer" class="JomPlayerContainer"><a id="JomTubePlayerId1" class="player1" href="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash">Get the Adobe Flash Player to see this video.</a></div>

  </body>

</html>

<?php

/*
$jwplayer_embed = "<div id=\"JomPlayerContainer\" class=\"JomPlayerContainer\">
<a id=\"JomTubePlayerId1\" class=\"player1\" href=\"http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash\">Get the Adobe Flash Player to see this video.</a>
</div>
";
return $jwplayer_embed;
*/

?>

Use trim() here:$flv_link       = trim($getflvlink);

trim — Strip whitespace (or other characters) from the beginning and end of a string

There was a newline at the end of the string that broke the JavaScript line into two lines.

i will give a shot and see if it works.. as i was hoping you could help since you seem the most helpful and top programmer around here..

your support and time helping everyone is much appreciated by everyone as you can see from there posts..

hopefully i get this working.. i report back.. i take your example and go from there

Updated a bit to include the cURL functions with a live feed.

<?php

//...get direct FLV link for Dailymotion

//http://www.dailymotion.com/us/featured/channel/sport/video/x8kqo2_bsides-salto-base-nocturno-en-ensan_sport
//http://keepvid.com/?url=http://www.dailymotion.com/us/featured/channel/sport/video/x8kqo2_bsides-salto-base-nocturno-en-ensan_sport
//http://vid.akm.dailymotion.com/18/512x384/h264/14404610.h264?aksessionid=1236484818170_912376&akauth=1236657618_89762dcab95c2ecae031f3b333df7437

//$geturl = $video_detail->video_url; // retrieve video_url from the database
//$geturl = "http://keepvid.com/?url=" . $video_detail->video_url;
$geturl = "http://keepvid.com/?url=http://www.dailymotion.com/us/featured/channel/sport/video/x8kqo2_bsides-salto-base-nocturno-en-ensan_sport";

if(function_exists('curl_init'))
{
  $ch      = curl_init();
  $timeout = 30; // set to zero for no timeout
  curl_setopt($ch, CURLOPT_URL, $geturl);
  curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
  curl_setopt($ch, CURLOPT_CONNECTTIMEOUT,$timeout);
  $file_contents = curl_exec($ch);
  curl_close($ch);
}

$start_position = strpos($file_contents, "Links found on");
$start_position = strpos($file_contents, "Report any problems to", $start_position);
$start_position = strpos($file_contents, "<a href=\"", $start_position) + 9;
$end_position   = strpos($file_contents, "\"", $start_position) - $start_position;
$getflvlink     = substr($file_contents, $start_position, $end_position);
$flv_link       = trim($getflvlink);

//$flv_link = "http://proxy-35.dailymotion.com/16/320x240/flv/7746594.flv?3729391860564098ca7ed38576d57c4e13a7dae";
//$flv_link = "http://vid.akm.dailymotion.com/18/512x384/h264/14404610.h264?aksessionid=1236484818170_912376&akauth=1236657618_89762dcab95c2ecae031f3b333df7437";

?>

<html>

  <head>

    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/swfobject/2.1/swfobject.js"></script>

    <script type="text/javascript">
      var flashvars =
      {
        'file':                      encodeURIComponent('<?php echo $flv_link; ?>'),
        'type':                     'video',
        'skin':                     'bright',
        'controlbar':               'over',
        'stretching':               'uniform',
        'frontcolor':               'FFFFFF',
        'lightcolor':               'FF6600',
        'autostart':                'true'
      };

      var params =
      {
        'allowfullscreen':          'true',
        'allowscriptaccess':        'always'
      };

      var attributes =
      { 
        'name':                     'JomPlayerId1',
        'id':                       'JomPlayerId1'
      };

      swfobject.embedSWF('player-4.4.162.swf', 'JomTubePlayerId1', '640', '500', '9.0.124', false, flashvars, params, attributes);
    </script>

  </head>

  </body>

    <div id="JomPlayerContainer" class="JomPlayerContainer"><a id="JomTubePlayerId1" class="player1" href="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash">Get the Adobe Flash Player to see this video.</a></div>

  </body>

</html>

crap that was it.... i got mixed up with right and left :( haaaaaa.. i saw the white space and meant to use rtrim.. but even that i should just used trim..

i am learning... thanks

here is for anyone as the possibilities maybe endless to add videos embedded in jwplayer.. test out with other supported servers..

<?php

// ##################################################
// ########### GET DIRECT FLV LINK FROM DAILYMOTION
// ##################################################

$geturl = "http://keepvid.com/?url=http://www.dailymotion.com/video/x72vn_mixedmartialarts_sport";
//$geturl = $video_detail->video_url; // RETRIEVE video_url FROM THE DATABASE

if (function_exists('curl_init')){
$ch=curl_init();
$timeout=30; // set to zero for no timeout
curl_setopt($ch,CURLOPT_URL, $geturl);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,$timeout);
$file_contents=curl_exec($ch);
curl_close($ch);
}

$start_position = strpos($file_contents, "Links found on");
$start_position = strpos($file_contents, "Report any problems to", $start_position);
$start_position = strpos($file_contents, "<a href=\"", $start_position)+9;
$end_position = strpos($file_contents, "\"", $start_position)-$start_position;
$getflvlink = substr($file_contents, $start_position, $end_position);
$flv_link = trim($getflvlink);
echo
"[".$flv_link."]";

//$flv_link = "http://proxy-35.dailymotion.com/16/320x240/flv/7746594.flv?3729391860564098ca7ed38576d57c4e13a7dae";
?>

<html>

  <head>

    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/swfobject/2.1/swfobject.js"></script>

    <script type="text/javascript">
      var flashvars =
      {
        'file':                     '<?php echo $flv_link;?>',
        'type':                     'video',
        'skin':                     'bright',
        'controlbar':               'over',
        'stretching':               'uniform',
        'frontcolor':               'FFFFFF',
        'lightcolor':               'FF6600',
        'autostart':                'true'
      };

      var params =
      {
        'allowfullscreen':          'true',
        'allowscriptaccess':        'always'
      };

      var attributes =
      {
        'name':                     'JomPlayerId1',
        'id':                       'JomPlayerId1'
      };

      swfobject.embedSWF('player.swf', 'JomTubePlayerId1', '640', '500', '9.0.124', false, flashvars, params, attributes);
    </script>

  </head>

  </body>

    <div id="JomPlayerContainer" class="JomPlayerContainer"><a id="JomTubePlayerId1" class="player1" href="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash">Get the Adobe Flash Player to see this video.</a></div>

  </body>

</html>

<?php

/*
$jwplayer_embed = "<div id=\"JomPlayerContainer\" class=\"JomPlayerContainer\">
<a id=\"JomTubePlayerId1\" class=\"player1\" href=\"http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash\">Get the Adobe Flash Player to see this video.</a>
</div>
";
return $jwplayer_embed;
*/

?>

how can i make this code work so i can play the video in jwplayer site,,not joomla

@wiol,

The code that I posted above, on Mar. 8, 2009, is standalone. It has nothing to do with Joomla and will run exactly as posted; that's how I tested it.

lefty i tested the code,but its not working.can you confirmed that the code not work??

@wiol,

NO, I'm very sorry, I can't do that — because it does work.

     http://willswonders.myip.org:8082/dailymotion.php

                                                                                            :D

Just in case I accidentally made some tiny little change, here's the code again:

<?php

//...get direct FLV link for Dailymotion

//http://www.dailymotion.com/us/featured/channel/sport/video/x8kqo2_bsides-salto-base-nocturno-en-ensan_sport
//http://keepvid.com/?url=http://www.dailymotion.com/us/featured/channel/sport/video/x8kqo2_bsides-salto-base-nocturno-en-ensan_sport
//http://vid.akm.dailymotion.com/18/512x384/h264/14404610.h264?aksessionid=1236484818170_912376&akauth=1236657618_89762dcab95c2ecae031f3b333df7437

//$geturl = $video_detail->video_url; // retrieve video_url from the database
//$geturl = "http://keepvid.com/?url=" . $video_detail->video_url;
$geturl = "http://keepvid.com/?url=http://www.dailymotion.com/us/featured/channel/sport/video/x8kqo2_bsides-salto-base-nocturno-en-ensan_sport";

if(function_exists('curl_init'))
{
  $ch      = curl_init();
  $timeout = 30; // set to zero for no timeout
  curl_setopt($ch, CURLOPT_URL, $geturl);
  curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
  curl_setopt($ch, CURLOPT_CONNECTTIMEOUT,$timeout);
  $file_contents = curl_exec($ch);
  curl_close($ch);
}

$start_position = strpos($file_contents, "Links found on");
$start_position = strpos($file_contents, "Report any problems to", $start_position);
$start_position = strpos($file_contents, "<a href=\"", $start_position) + 9;
$end_position   = strpos($file_contents, "\"", $start_position) - $start_position;
$getflvlink     = substr($file_contents, $start_position, $end_position);
$flv_link       = trim($getflvlink);

//$flv_link = "http://proxy-35.dailymotion.com/16/320x240/flv/7746594.flv?3729391860564098ca7ed38576d57c4e13a7dae";
//$flv_link = "http://vid.akm.dailymotion.com/18/512x384/h264/14404610.h264?aksessionid=1236484818170_912376&akauth=1236657618_89762dcab95c2ecae031f3b333df7437";

?>

<html>

  <head>

    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/swfobject/2.1/swfobject.js"></script>

    <script type="text/javascript">
      var flashvars =
      {
        'file':                      encodeURIComponent('<?php echo $flv_link; ?>'),
        'type':                     'video',
        'skin':                     'bright',
        'controlbar':               'over',
        'stretching':               'uniform',
        'frontcolor':               'FFFFFF',
        'lightcolor':               'FF6600',
        'autostart':                'true'
      };

      var params =
      {
        'allowfullscreen':          'true',
        'allowscriptaccess':        'always'
      };

      var attributes =
      { 
        'name':                     'JomPlayerId1',
        'id':                       'JomPlayerId1'
      };

      swfobject.embedSWF('player-4.4.162.swf', 'JomTubePlayerId1', '640', '500', '9.0.124', false, flashvars, params, attributes);
    </script>

  </head>

  </body>

    <div id="JomPlayerContainer" class="JomPlayerContainer"><a id="JomTubePlayerId1" class="player1" href="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash">Get the Adobe Flash Player to see this video.</a></div>

  </body>

</html>

@lefty
i got it working.sorry for late reply,but some videos not play.Like this one http://www.dailymotion.com/video/x3fmnv ,keepvid give en as return..You can play this video on your site??plzz if you have solution,can you share??

thannxxx

Hi all.
I'm reading all comment.Now,i have a solution.But in my country (Vietnamese),network so bad.I can play dailymotion.com video ,when get directlink so low,but when play,i see it is very good.
And with youtube,i see so nice.
And now,i'll give demos :

- Youtube API :
http://forum.phoxitin.com/music.pxt?do=song&id=9930

-Dailymotion :
http://forum.phoxitin.com/music.pxt?do=song&id=9913

Waiting for a few comment.Let's tell me about it.

My Y!M : thanhlongcongtu_vn

I have a question:

When I press on play button of dailymotion's flash player, it not play and open a new page (to dailymotion)

View it for detail:

http://giaisau.info/movie/videos/view/247/8