javascript 使用 jquery 暂停 mediaelement.js
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/7729305/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-26 01:05:34 来源:igfitidea点击:
Pause mediaelement.js using jquery
提问by evolutionxbox
I have initialised the element using:
我已经使用以下方法初始化了元素:
$('video').mediaelementplayer();
Now I would like to target that video and pause it when a link is pressed:
现在我想定位该视频并在按下链接时暂停它:
$('.page_button').live('click', function() {
$('video').pause();
});
Thanks.
谢谢。
回答by Brian Nickel
Each element with a media player element has a player property defined. This is where all the methods reside. You can access it with either of the following methods:
每个带有媒体播放器元素的元素都定义了一个播放器属性。这是所有方法所在的地方。您可以使用以下任一方法访问它:
$('video')[0].player.pause(); // Be sure the video element exists.
$('video').each(function(){this.player.pause()}) // Safe.