disabling play/pause in embedded video using JW player

不羁岁月 提交于 2019-12-01 00:37:58

Ahhh yes, there used to be functionality in the player to do this (about ignoring the click) but it seems it keeps getting removed.

Here's the solution I've just implemented that works for me, I simply plug into the onPause javascript event and start the media playing again.

    <script type='text/javascript'>
  jwplayer('mediaspace').setup({
    'flashplayer': '/jw/player.swf',
    'file': 'http://d3usowdy51yate.cloudfront.net/your-mp4-goes-here.mp4',
    'autostart': 'true',
    'icons': 'true',
    'stretching': 'fill',
    'controlbar': 'none',
    'width': '640',
    'height': '360',
    events: {
        onPause: function(event) {
          jwplayer('mediaspace').play();}
    }
  });
</script>

Try to put a transparent div over the player with the same dimension of the player.

You can use the CSS property pointer-events on the #mediaplayer to prevent the click event to go trough to the video:

#mediaplayer {
    pointer-events: none;
}

You could also abuse the onPause event as a fallback for older browsers <IE9, by saying; play the video if the pause event is executed:

jwplayer('mediaplayer').setup({
    flashplayer: 'player.swf',
    file: 'video.mp4',
    controlbar: 'none',
    width: '1000',
    height: '1000',
    autostart: 'true',
    events: {
        onPause: function() {
            this.play(true);
        }
    }
});
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!