• Resolved Philipp

    (@philippmuenchen)


    First of all: THANK YOU! This Plugin is amazing and very useful. I love to work with it!

    I’ve a question to the usage of another player. I’m already using sublime video player (https://sublimevideo.net/) on a whole website but would love to combine it with your Plugin. So I already found out how to grab the poster image from the database. But now I would love to get the <source=”XXX”…> <format=”YYY”> also for every generated media file as your plugin outputs.
    Is there a “foreach” code to use outside your plugin? That would be fantastic.

    Thanks a lot for your great work!

    Philipp

    https://www.ads-software.com/extend/plugins/video-embed-thumbnail-generator/

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Kyle Gilman

    (@kylegilman)

    I’m not sure of the exact method you’ll want to use, but I can point you in the right direction I think. Any video encoded by the plugin is saved as a child of the original video. There are a lot of locations I look for because a user could provide their own alternate formats, but I start with a query to get all the videos that are children of the video then loop through all the possible formats. That should work for your purposes. Here’s some sample code to get you started. I haven’t tested this, so I don’t know if it will work exactly as written.

    $postID = get_the_ID(); //assuming you're doing this in the Loop
    
    $args = array(
    	'numberposts' => '-1',
    	'post_parent' => $postID,
    	'post_type' => 'attachment',
    	'post_mime_type' => 'video'
    );
    $children = get_posts( $args );
    
    $video_formats = array( //setting up all the possible formats
    	"rotated" => array("type" => "h264", "suffix" => "-rotated.mp4"),
    	"1080" => array("name" => "1080p H.264", "width" => 1920, "height" => 1080, "type" => "h264", "suffix" => "-1080.mp4", "old_suffix" => "-1080.m4v"),
    	"720" => array("name" => "720p H.264", "width" => 1280, "height" => 720, "type" => "h264", "suffix" => "-720.mp4", "old_suffix" => "-720.m4v"),
    	"mobile" => array("name" => "480p H.264", "width" => 640, "height" => 480, "type" => "h264", "suffix" => "-480.mp4", "old_suffix" => "-ipod.m4v"),
    	"webm" => array("name" => "WEBM", "width" => 0, "height" => 0, "type" => "webm", "suffix" => ".webm"),
    	"ogg" => array("name" => "OGV", "width" => 0, "height" => 0, "type" => "ogv", "suffix" => ".ogv")
    );
    
    foreach ( $video_formats as $format => $format_stats ) {
    	if ($children) {
    		foreach ( $children as $child ) {
    			$mime_type = get_post_mime_type($child->ID);
    			$wp_attached_file = get_post_meta($child->ID, '_wp_attached_file', true);
    			if ( substr($wp_attached_file, -strlen($format_stats['suffix'])) == $format_stats['suffix'] ) {
    				$url = $uploads['baseurl'].'/'.$wp_attached_file;
    				echo '<source="'.$url.'" type="'.$mime_type.'">'; //or whatever info your player needs
    			}
    		}
    	}
    }
    Thread Starter Philipp

    (@philippmuenchen)

    Kyle,

    thank you so much! That really helped… I struggled for a couple of hours but from the moment I realized that your $postID has to be the single “attachement ID” it was easy to get it running! ??

    So thanks again for the hint!

    Plugin Author Kyle Gilman

    (@kylegilman)

    Oh right, get_the_ID() would give you the ID of the current post, not the video attachment you were looking for. Sorry about that. Glad you got it working.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Usage of another player’ is closed to new replies.