New Landing How can we help? Themeforest Theme Support Dante Fullscreen Video Embed for Youtube Playlists

Viewing 5 posts - 1 through 5 (of 5 total)
  • Posted in: Dante
  • #75021
    st_bo
    Member
    Post count: 23

    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!

    #75340
    Mohammad – SUPPORT
    Moderator
    Post count: 27441

    Hi,
    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 Ideas

    #78988
    st_bo
    Member
    Post count: 23

    Hi 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, St

    #79004
    st_bo
    Member
    Post count: 23

    Hi, 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.

    #79287
    Swift Ideas – Ed
    Keymaster
    Post count: 15264

    Hi @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

Viewing 5 posts - 1 through 5 (of 5 total)

You must be logged in and have valid license to reply to this topic.

License required for one of the following items
Login and Registration Log in · Register