Name is required.
Email address is required.
Invalid email address
Answer is required.
Exceeding max length of 5KB

Play dailymotion example


I made a little example how to play a single HD video from dailymotion

bc.. //Single Dailymotion video with the JW player
//EXAMPLE
//http://www.dailymotion.com/video/x2q0rp_amy-winehouse-stronger-than-me_music
//$videocode will be x2q0rp_amy-winehouse-stronger-than-me_music or use just this code x2q0rp


$videocode = 'x2q0rp_amy-winehouse-stronger-than-me_music';

// set video data feed URL
$feedURL = 'http://www.dailymotion.com/atom/video/' . $videocode;

// read feed into SimpleXML object
if(!$sxml = @simplexml_load_file($feedURL))
{
echo '<div style="width:470px; height:320px;border: 1px solid #000;">No connection to the Dailymotion server or a wrong url !</div>';
return;
}

// Find out the link to the first FLV
$linksurl = $sxml->entry->children('http://www.w3.org/2005/Atom');

$linkproperties = array('enclosure');
foreach($linkproperties as $content){
$$content = null;
$exit = false;
foreach($linksurl as $links) {
if($exit){
continue;
}
foreach($links->attributes() as $keys => $values) {
if($keys == 'href'){
$$content = (string) $values;
}
if (stristr ($values , $content) == TRUE) {
$exit = true;
}

}
}
if(!$exit){
$$content = null;
}
}
?>

<div id="player">This text will be replaced</div>

<script type="text/javascript">

var so = new SWFObject('http://www.longtailvideo.com/jw/embed/player.swf','mpl','470','320','9');
so.addParam('allowscriptaccess','always');
so.addParam('allowfullscreen','true');
so.addParam('flashvars','&file=<?=$enclosure; ?>&autostart=true&stretching=fill');
so.write('player');
</script>

23 Community Answers

JW Player

User  
0 rated :

can you please share what we gonna do with all this code ?

JW Player

User  
0 rated :

It's simple.
This is just an example how to play a dailymotion video in the JW player.
I see I forgot to put <?php above the script :)

http://www.dailymotion.com/video/x7steh_talentshow-introduction-of-remi-wal_music

is calling an atom feed

bc.. <?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
<title>Talentshow - Introduction of Remi Walsarie</title>
<published>2008-12-21T22:11:58+01:00</published>
<updated>2008-12-29T12:25:39+01:00</updated>
<id>http://www.dailymotion.com/video/x7steh_talentshow-introduction-of-remi-wal_music</id>
<entry>
<link rel="alternate" type="text/xhtml" href="/video/x7steh_talentshow-introduction-of-remi-wal_music" title="Talentshow - Introduction of Remi Walsarie"/>
<link rel="enclosure" title="Talentshow - Introduction of Remi Walsarie" width="320" height="240" href="http://www.dailymotion.com/get/18/320x240/flv/13101785.flv?key=626d05de0c7988f2b32b6b9d7b9459481392f65.flv" type="video/x-flv"/>
<link rel="enclosure" title="Talentshow - Introduction of Remi Walsarie" width="80" height="60" href="http://www.dailymotion.com/get/18/80x60/flv/13101785.flv?key=626d05de0c7988f2b32b6b9d7b9459481392f65.flv" type="video/x-flv"/>
<link rel="enclosure" title="Talentshow - Introduction of Remi Walsarie" width="320" height="240" href="http://www.dailymotion.com/get/16/320x240/on2/13101785.on2?key=626d05de0c7988f2b32b6b9d7b9459481392f65.on2" type="video/unknown"/>
<link rel="enclosure" title="Talentshow - Introduction of Remi Walsarie" width="512" height="384" href="http://www.dailymotion.com/get/18/512x384/h264/13101785.h264?key=626d05de0c7988f2b32b6b9d7b9459481392f65.h264" type="video/unknown"/>
<link rel="enclosure" title="Talentshow - Introduction of Remi Walsarie" width="1280" height="720" href="http://www.dailymotion.com/get/16/1280x720/on2/13101785.on2?key=626d05de0c7988f2b32b6b9d7b9459481392f65.on2" type="video/unknown"/>
<link rel="enclosure" title="Talentshow - Introduction of Remi Walsarie" width="1280" height="720" href="http://www.dailymotion.com/get/16/1280x720/h264/13101785.h264?key=626d05de0c7988f2b32b6b9d7b9459481392f65.h264" type="video/unknown"/>
<link rel="enclosure" title="Talentshow - Introduction of Remi Walsarie" width="848" height="480" href="http://www.dailymotion.com/get/15/848x480/on2/13101785.on2?key=626d05de0c7988f2b32b6b9d7b9459481392f65.on2" type="video/unknown"/>
<link rel="enclosure" title="Talentshow - Introduction of Remi Walsarie" width="848" height="480" href="http://www.dailymotion.com/get/18/848x480/h264/13101785.h264?key=626d05de0c7988f2b32b6b9d7b9459481392f65.h264" type="video/unknown"/>
<link rel="enclosure" title="Talentshow - Introduction of Remi Walsarie" width="1280" height="720" href="http://www.dailymotion.com/swf/k2GBuhlwVuQZrqSYn7" type="application/x-shockwave-flash"/>
<link rel="enclosure" type="image/jpeg" href="http://ak.static.dailymotion.com/preview/13101785.jpg?20081229122539" title="Talentshow - Introduction of Remi Walsarie"/>
<link rel="prev" type="application/atom+xml" href="http://www.dailymotion.com/video/x7stei_cod4-fr08_videogames" title="COD4 FR08"/>
<link rel="next" type="application/atom+xml" href="http://www.dailymotion.com/video/x7stef_mrde_people" title="M?R?DE"/>
<title>Talentshow - Introduction of Remi Walsarie</title>
<published>2008-12-21T22:11:58+01:00</published>
<updated>2008-12-29T12:25:39+01:00</updated>
<id>http://www.dailymotion.com/video/x7steh_talentshow-introduction-of-remi-wal_music</id>
<author><name>itv1</name>
<uri>http://www.dailymotion.com/atom/itv1</uri>
</author>
<content type="html">The Talentshow - Introduction of Remi Walsarie</content>
<category term="muziek" scheme="http://www.dailymotion.com/tag/muziek"/>
<category term="singer" scheme="http://www.dailymotion.com/tag/singer"/>
<category term="songwriter" scheme="http://www.dailymotion.com/tag/songwriter"/>
<category term="remi" scheme="http://www.dailymotion.com/tag/remi"/>
<category term="walsarie" scheme="http://www.dailymotion.com/tag/walsarie"/>
<category term="crossmania" scheme="http://www.dailymotion.com/tag/crossmania"/>
<category term="itv1" scheme="http://www.dailymotion.com/tag/itv1"/>
<category term="heiloo" scheme="http://www.dailymotion.com/tag/heiloo"/>
<category term="city:Heiloo" scheme="http://www.dailymotion.com/tag/city:Heiloo"/>
<category term="country:NL" scheme="http://www.dailymotion.com/tag/country:NL"/>
<category term="state:North Holland" scheme="http://www.dailymotion.com/tag/state:North Holland"/>
<category term="user-category:music" scheme="http://www.dailymotion.com/tag/user-category:music"/>
</entry>
</feed>



If you want the thumbnail to just call it like this

http://www.dailymotion.com/thumbnail/video/x7steh_talentshow-introduction-of-remi-wal_music

It will return this thumbnail http://ak.static.dailymotion.com/dyn/preview/320x240/13101785.jpg?20081229122539


JW Player

User  
0 rated :

I am using php script for Dailymotion Videos its working but when we go for Low Quality & High Quality, When on High Quality the video is not streaming but its downloads the entire video and then it is playing

I need a PHP Script to play the video using streaming itself
Please anybody having post it.

JW Player

User  
-1 rated :

I think you are confused with youtube.
Dailymotion doesn't use different quality's video

JW Player

User  
0 rated :

There is a Button named "HQ" in the Dailymotion site It gives high quality
If we click that the quality will be good.

JW Player

User  
0 rated :

I know it's there but both will stream normally
Here an example when using the script above

http://www.cfcms.nl/youtube-videos.html

(the last two video's)

and here with another script I made
http://www.imageflow.nl/imageflow-dailymotion.php

JW Player

User  
0 rated :

@ceasar

No connection to the Dailymotion server or a wrong url !

JW Player

User  
0 rated :

In my examples it's working so it must be something server related
This script needs php5 to get it work

http://www.cfcms.nl/youtube-videos.html

(the last two video's)

First call this in your browser
http://www.dailymotion.com/atom/video/x2q0rp_amy-winehouse-stronger-than-me_music and see if you will get any response

Also you can remove the @ @simplexml_load_file($feedURL)) to see any errors
simplexml_load_file($feedURL))

JW Player

User  
0 rated :

my Setting:

PHP Version: 5.2.6

PHP Built on: Windows NT WEB-A8BAC1CD758 5.1 build 2600

Web Server: Apache

Web Server to PHP interface: apache2handler

JW Player

User  
0 rated :

I see it now.
It is strange that locally it works but from my server I get the same message.
It seems to be forbidden by Dailymotion.

You will get an forbidden page on dailymotion

I didn't knew that.

Sorry for this post.

JW Player

User  
0 rated :

I see the problem :)

This is the complete url to the flv

http://www.dailymotion.com/get/14/320x240/flv/4573285.flv?key=84899632cae300569200c70c9d55d5221393c42.flv

The player stops at the first.flv so it will be

http://www.dailymotion.com/get/14/320x240/flv/4573285.flv and then you will get an forbidden page

I will see if I can fix this

I made an online example

http://www.cfcms.nl/dailymotiontest.php

JW Player

User  
0 rated :

It seems that dailymotion blocked complete IP ranges.
My complete server park has been blocked that's why it didn't worked.
I think the same happen to IG
If you look at their site there are more people with the same problem
http://blog.dailymotion.com/2008/11/13/faq-review/#comments
IF this ever will be fixed then my example will also work again :)
For now I cannot take dailymotion seriously so don't use it

JW Player

User  
0 rated :

This piece of code works very nicely on my local computer, but not on my server that has public access. So dailymotion doesn't allow playing their videos in our own JW player? that's so bad

JW Player

User  
0 rated :

Hi,

Anybody can post me the High Quality Video for Dailymotion.com I need it very urgently,

Please Help me

JW Player

User  
0 rated :

Soo dose this still work?? and dose it work for all dailymotion videos?

JW Player

User  
0 rated :

Also wondering if this still works, and if not, what does?

JW Player

User  
0 rated :

If it is not working from a production server, it might be simply because the firewall doesn't allow external connections. Some hosting companies simply close the firewall for all outgoing connections.

For one of my sites, I had to ask the hosting company to open the firewall for specific IP addresses. This can be a problem if you have to access some CDNs like Amazon S3 or Akamai.

If it's not the firewall, it might be because the PHP settings doesn't allow opening files from external URL.
I don't know how simplexml gets the distant file, but if it uses fopen($url) you'll have to check PHP settings to see if "allow_url_fopen" is not disabled.

JW Player

User  
0 rated :

@ceasar
see: http://fr.php.net/manual/fr/function.simplexml-load-file.php

simple test:
bc.. <?php

$filexml="http://www.dailymotion.com/atom/video/x2q0rp_amy-winehouse-stronger-than-me_music.xml";

if (file_exists($filexml)) {

$xml = @simplexml_load_file($filexml);
print_r($xml);

} else {

exit("wrong url !<a href=\"$filexml\" target=\"_blank\">($filexml)</a>");

}

?>



Result:
bc.. wrong url !(http://www.dailymotion.com/atom/video/x2q0rp_amy-winehouse-stronger-than-me_music.xml)

JW Player

User  
0 rated :

I thought some might be interested in my latest project: http://wessite.com/labs/dailymotionprovider

JW Player

User  
0 rated :

That's a good player, but does it support playlists and, if so, can they be youtube / dailymotion mixed?

Ethan Feldman

JW Player Support Agent  
0 rated :

Yes it supports playlists. YouTube – yes, DailyMotion – no.

JW Player

User  
0 rated :

@wessite I checked out your projects, it plays the dailymotion video just but Vimeo version doesn't load within the JW Player, I just see the default Vimeo player.

Ethan Feldman

JW Player Support Agent  
0 rated :

@Chozen – That is just how that particular provider works…

This question has received the maximum number of answers.