Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

mediaelement.js - pause/play onclick for video?

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

like image 386
DamnSemicolon Avatar asked Oct 12 '22 07:10

DamnSemicolon


1 Answers

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

just try it :)

like image 56
claw68 Avatar answered Oct 14 '22 03:10

claw68