Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //function to parse a video url
- function eyeconnect_getvideoinfo($vid_link)
- {
- // youtube get video id
- if (strpos($vid_link, 'youtube'))
- {
- // regular links
- if (preg_match('/(?<=v\=)([\w\d-_]+)/', $vid_link, $matches))
- return array('host_name' => 'youtube', 'original_key' => $matches[0],'vid_link' => $vid_link);
- // ajax hash tag links
- else if (preg_match('#([\d\w-_]+)$#i', $vid_link, $matches))
- return array('host_name' => 'youtube', 'original_key' => $matches[0],'vid_link' => $vid_link);
- else
- return FALSE;
- }
- // vimeo get video id
- elseif (strpos($vid_link, 'vimeo'))
- {
- if (preg_match('#(?<=/)([\d]+)#', $vid_link, $matches))
- return array('host_name' => 'vimeo', 'original_key' => $matches[0],'vid_link' => $vid_link);
- else
- return FALSE;
- }
- // dailymotion.com get video id
- elseif (strpos($vid_link, 'dailymotion'))
- {
- /*
- if (preg_match('#(?<=/)([\d]+)#', $vid_link, $matches))
- return array('host_name' => 'dailymotion', 'original_key' => $matches[0]);
- else
- return FALSE;
- */
- $id = strtok(basename($vid_link), '_');
- if($id != '')
- return array('host_name' => 'dailymotion', 'original_key' => $id, 'vid_link' => $vid_link);
- else
- return FALSE;
- }
- else
- return FALSE;
- }
- //using the function
- if($videourl != ''){
- $videoinfo = eyeconnect_getvideoinfo($videourl);
- //var_dump($videoinfo);
- if(is_array($videoinfo)){ //if valid video links
- $hostname = $videoinfo['host_name'];
- $videoid = $videoinfo['original_key'];
- if($hostname == 'youtube'){
- //$string = 'http://www.youtube.com/watch?v=A7izsd5IXq8&playnext=1&list=PL6753173C0F0BE9ED';
- $url = parse_url($videourl);
- parse_str($url['query'],$q);
- $list = $q['list'];
- //var_dump($list);
- if($list != ''){
- $list = substr($list, 2);
- //echo '<iframe src="http://www.youtube.com/embed/p/ID" width="100%" height="500" frameborder="0"></iframe>';
- echo '<iframe width="520" height="320" src="http://www.youtube.com/p/'.$list.'?fs=1&version=3&autoplay=1" frameborder="0" allowfullscreen></iframe>';
- }
- else{
- echo '<iframe width="520" height="320" src="http://www.youtube.com/v/'.$videoid.'&autoplay=1" frameborder="0" allowfullscreen></iframe>';
- }
- }
- else if($hostname == 'vimeo')
- {
- //echo '<iframe src="http://player.vimeo.com/video/'.$videoid.'?title=0&byline=0&portrait=0" width="520" height="320" frameborder="0"></iframe>';
- echo '<object width="520" height="320"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="movie" value="http://vimeo.com/moogaloop.swf?clip_id='.$videoid.'&server=vimeo.com&show_title=1&show_byline=0&show_portrait=0&color=00adef&fullscreen=1&autoplay=1&loop=0" /><embed src="http://vimeo.com/moogaloop.swf?clip_id='.$videoid.'&server=vimeo.com&show_title=1&show_byline=0&show_portrait=0&color=00adef&fullscreen=1&autoplay=1&loop=0" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="520" height="320"></embed></object>';
- }
- else if($hostname == 'dailymotion')
- {
- $custom = get_post_custom($id);
- $videourl2 = $custom["videourl2"][0];
- if($videourl2 != ''){
- $videourl2 = basename($videourl2);
- echo '<iframe marginwidth="0" marginheight="0" width="520" height="500" frameborder="0" scrolling="no" src="http://www.dailymotion.com/videozap/playlist/'.$videourl2.'?position=bottom&auto=1"></iframe>';
- }
- else{
- echo '<iframe frameborder="0" width="520" height="320" src="http://www.dailymotion.com/embed/video/'.$videoid.'?width=328"></iframe>';
- }
- }
- }
- }//end if video url found in meta box
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement