Is there a way to display a video using only the default video player of the browser, without the mejs
/ wp-video
interface? The additional markup gives me a lot of trouble. I just want to use the <video>
element, and handle my custom needs with CSS/JS.
I won't say I'm an expert. I have considerable amount of experience with custom templates and hooks, but I can't figure this one out.
Is there a way to display a video using only the default video player of the browser, without the mejs
/ wp-video
interface? The additional markup gives me a lot of trouble. I just want to use the <video>
element, and handle my custom needs with CSS/JS.
I won't say I'm an expert. I have considerable amount of experience with custom templates and hooks, but I can't figure this one out.
I've found the right way digging through the WP documentation: https://developer.wordpress/reference/hooks/wp_video_shortcode/
This code seems to do the trick:
function buildVideoPlayer($output, $attr)
{
// $output contains the default HTML string, created by the WP core
// $attr is an associative array, which contains the parameters
// (src, poster, preload, etc.) specified in the shortcode
// The following piece of HTML string will replace the default WP video player
return "<video src='".$attr["mp4"]."'></video>";
}
add_filter("wp_video_shortcode", "buildVideoPlayer", 10, 2);
Make sure to pass how many parameters do you want to catch in add_filter()
. The default value is 1, but wp_video_shortcode
has 4, and in this code, I needed the 2nd one.
I would try to use the embed_oembed_html filter
Here is an ultra basic example
add_filter('embed_oembed_html','oembed_video_add_wrapper',10,4);
function oembed_video_add_wrapper( $cache, $url, $attr, $post_ID) {
return sprintf('<video src="%s">',$url);
}