gpt4 book ai didi

youtube - YouTube Upload Widget/OnStateChange事件监听器

转载 作者:行者123 更新时间:2023-12-03 06:33:18 25 4
gpt4 key购买 nike

我正在尝试使用onStateChange事件监听器对YouTube上载小部件进行调用,这取决于上载小部件的状态,但是我似乎无法使onStateChange事件监听器与上载小部件一起使用。请参阅下面的代码。奇怪的是,当我使用相同的技术为iframe播放器单独添加onStateChange侦听器时,它的效果就很好。有人有什么好主意吗?还是上传窗口小部件API只是 buggy ?

<script>    
var player;
var widget;
function onYouTubeIframeAPIReady() {
player1 = new YT.Player('player1', {
events: {

}
}
);

widget = new YT.UploadWidget('widget', {
events: {
'onStateChange': onWidgetStateChange,
'onUploadSuccess': onUploadSuccess,
'onProcessingComplete': onProcessingComplete
}
});
}

function onWidgetStateChange(event) {
if (event.data == YT.UploadWidgetState.RECORDING) {
player1.playVideo();
}
}

function onUploadSuccess(event) {
alert('Video ID ' + event.data.videoId + ' was uploaded and is currently being processed.');
}

function onProcessingComplete(event) {
player = new YT.Player('player', {
height: 390,
width: 640,
videoId: event.data.videoId,
events: {

}
});
}

最佳答案

我相信您的问题是您需要将event.data == YT.UploadWidgetState.RECORDING更改为event.data.state == YT.UploadWidgetState.RECORDING
进行更改时,我能够将一个jsfiddle组合在一起,几乎可以完成您想要的操作:http://jsfiddle.net/jeffposnick/yhWsG/35/

关于youtube - YouTube Upload Widget/OnStateChange事件监听器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17937637/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com