javascript - mediaelement.js - pauseplay onclick for video? - Stack Overflow

What's the easiest way to add pauseplay functionality by clicking anywhere in the video element s

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){

            $(this).play();

        } else {

            $(this).pause();

        }


    });

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

DS

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){

            $(this).play();

        } else {

            $(this).pause();

        }


    });

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

DS

Share Improve this question edited Mar 4, 2015 at 21:26 L84 46.3k59 gold badges181 silver badges259 bronze badges asked Apr 14, 2011 at 18:45 DamnSemicolonDamnSemicolon 2611 gold badge3 silver badges10 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 4
    $(".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 mands.

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

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744838382a4596402.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信