Mediaelement JS - Hiding mouse cursor when mouse not moving

194 views Asked by At

I have a small issue with mediaelement js. My player doesn't hide the mouse cursor when the mouse is not moving.

<script src="build/jquery.js"></script> 
<script src="build/mediaelement-and-player.js"></script>

<link rel="stylesheet" href="build/mediaelementplayer.css" />

<video width="850" height="350" id="player2" controls="controls">
<source src="http://127.0.0.1/publics/ip4.mp4" type="video/mp4">
<track kind="subtitles" src="iron.man.3.2013.720p.bluray.dts.x264-publichd.srt.txt"     srclang="en" /> 

 <script>
 $('audio,video').mediaelementplayer();
 </script>
1

There are 1 answers

0
zppinto On

I know it's an old topic but it can help someone...

var mHidden = false;
var j;

$(document).mousemove(function() {
    if (!mHidden) {
        mHidden = false;
        clearTimeout(j);
        $('#player2').css({cursor: 'default'});
        j = setTimeout(hide, 1000);
    }
});

function hide() {
        $('#player2').css({cursor: 'none'});
        mHidden = true;
        setTimeout(function() {
            mHidden = false;
        }, 500);
}