Digital experiences for all disciplines
New Landing › How can we help? › Themeforest Theme Support › Dante › Fullscreen Video Embed for Youtube Playlists
New Landing › How can we help? › Themeforest Theme Support › Dante › Fullscreen Video Embed for Youtube Playlists
- This topic has 4 replies, 3 voices, and was last updated 10 years by Swift Ideas – Ed.
-
Posted in: Dante
-
May 14, 2014 at 3:13 pm #75021
Hi,
I would like to use the Video Embed Function for Youtube Video Playlists.
Therefore I have to override sf_get_embed_src function (located in sf-media.php), as seen below:/* VIDEO EMBED FUNCTIONS ================================================== */ if (!function_exists('sf_video_embed')) { function sf_video_embed($url, $width = 640, $height = 480) { if (strpos($url,'youtube') || strpos($url,'youtu.be')){ return sf_video_youtube($url, $width, $height); } else { return sf_video_vimeo($url, $width, $height); } } } if (!function_exists('sf_video_youtube')) { function sf_video_youtube($url, $width = 640, $height = 480) { preg_match('/[\\?\\&]v=([^\\?\\&]+)/', $url, $video_id); return '<iframe itemprop="video" src="http://www.youtube.com/embed/videoseries?list='. $video_id[1] .'?wmode=transparent" width="'. $width .'" height="'. $height .'" ></iframe>'; } } if (!function_exists('sf_video_vimeo')) { function sf_video_vimeo($url, $width = 640, $height = 480) { preg_match('/http:\/\/vimeo.com\/(\d+)$/', $url, $video_id); return '<iframe itemprop="video" src="http://player.vimeo.com/video/'. $video_id[1] .'?title=0&byline=0&portrait=0?wmode=transparent" width="'. $width .'" height="'. $height .'"></iframe>'; } } if (!function_exists('sf_get_embed_src')) { function sf_get_embed_src($url) { if (strpos($url,'youtube')){ preg_match('/[\\?\\&]v=([^\\?\\&]+)/', $url, $video_id); if (isset($video_id[1])) { return 'http://www.youtube.com/embed/'. $video_id[1] .'?autoplay=1&wmode=transparent'; } } else { preg_match('/http:\/\/vimeo.com\/(\d+)$/', $url, $video_id); if (isset($video_id[1])) { return 'http://player.vimeo.com/video/'. $video_id[1] .'?title=0&byline=0&portrait=0&autoplay=1&wmode=transparent'; } } } }
Unfortunately, my php skills are too bad, so can anybody please help me to override this function?
I will give an example for a standard Youtube Video and a Youtube Playlist below. How is it possible to differentiate between a Video and Playlist URL and return the correct value that is show in the fullscreen? The fullscreen overlay should look like this link: http://www.youtube.com/embed/videoseries?list=PLSfNJgI6UBeDxDy95GCflWkDp4soh6wNJ
Youtube Video URL:
and Embed Code for Youtube Video:
<iframe width="560" height="315" src="//www.youtube.com/embed/V2O8xJtcOAA" frameborder="0" allowfullscreen></iframe>
Youtube Video Playlist:
and the quite similar Embed Code for the Youtube Video Playlist:
<iframe width="560" height="315" src="//www.youtube.com/embed/videoseries?list=PLSfNJgI6UBeDxDy95GCflWkDp4soh6wNJ" frameborder="0" allowfullscreen></iframe>
Thanks in advance!
May 15, 2014 at 2:37 pm #75340Hi,
I made changes for youtube video list in your posted code so please use this modified code and let me know that worked .Thanks 🙂
With Best Regards
Swift IdeasMay 30, 2014 at 10:05 am #78988Hi Mohammad,
can I place the code in the child theme functions.php? And if so, how to do it and not overwrite the sf-media.php in case of updates? Can this please be clearly stated in a knowledge base articel?
Additonally, thanks for the modified code, but is it possible to support both, (1) youtube video and (2) youtube playlists? I think one more if-then-else bash is necessary.
Your support is highly appreciated!
Thx, StMay 30, 2014 at 10:28 am #79004Hi, to add one more thing to the playlist function.
In the PB element “video player” (see screenshot), there is a description below the video link which states “Link to the video. More about supported formats at WordPress codex page.”
I checked the WordPress codex page and there is a note on YouTube that states that [only public and “unlisted”] videos and playlists are supported with WordPress 2.9 and above. Would be really cool if we can insert playlist as well as supported by WP.
June 1, 2014 at 1:11 pm #79287Hi @st_bo,
This isn’t yet supported as standard, you would need to modify the above function to make it work. I’d suggest you to use the strpos function to search for “videoseries” and then you can return a different URL based on that.
– Ed
-
Posted in: Dante
You must be logged in and have valid license to reply to this topic.