开发者

mediaelement.js - pause/play onclick for video?

开发者 https://www.devze.com 2023-02-25 02:32 出处:网络
What\'s the easiest way to add pause/play functionality by clicking anywhere in the video element similar to most video players?

What's the easiest way to add pause/play functionality by clicking anywhere in the video element similar to most video players?

I tried:

$('video').click(function() {

        if($(this).paused){

开发者_JAVA技巧            $(this).play();

        } else {

            $(this).pause();

        }


    });

But it didn't like the $(this).pause() call. Any help is appreciated. Thanks.

DS


    $(".mejs-mediaelement").click(function(){
        if($(".mejs-overlay-play").css('display') == 'none'){
            $('video').each(function(){this.player.pause()});
        }
    });

just try it :)


$('video').click(function() {

        if(this.paused){

            this.play();

        } else {

            this.pause();

        }


    });

But, this won't work. You will want to float an invisible div (with an invisible PNG in it) over the video to receive the click commands.

Or you can use a solution like http://videojs.com/

0

精彩评论

暂无评论...
验证码 换一张
取 消