这个脚本工作得很好,但是如果启动了一个新视频,它所做的就是停止一个正在播放的视频的实例。当调用函数stopAllButMe();时,我如何重写它来停止播放视频的所有实例?
function stopAllButMe(playerState, player) {
if (playerState=='PLAYING') {
var myId = player.getId();
projekktor('*').each(function() {
if (this.getId()!==myId) {
this.setStop();
}
});
}
}
projekktor('*').each(function() {
this.addListener('state', stopAllButMe);
});发布于 2012-02-02 06:21:56
function stopAllButMe(playerState) {
if (playerState=='PLAYING') {
projekktor('*').each(function() {
this.setStop();
});
}
}
projekktor('*').each(function() {
this.addListener('state', stopAllButMe);
});“if”语句正在根据输入进行检查。
发布于 2012-02-02 06:22:38
function stopAllButMe (state, player) {
//iterate through each of the `<video>` elements
$.each($('video'), function () {
//check if the current iteration is the same element that got passed into this function
if (this.id != player.id) {
//stop any `<video>` element that isn't the one passed into this function
this.stop();
}
});
}
//find each `<video>` element and add an event handler for the `state` event
$('video').bind('state', stopAllButMe);这里假设每个<video>标记都有自己的惟一ID。
https://stackoverflow.com/questions/9104205
复制相似问题