gpt4 book ai didi

youtube-iframe-api - YouTube Java Script player.setPlaybackRate() API 不再有效

转载 作者:行者123 更新时间:2023-12-02 04:26:13 24 4
gpt4 key购买 nike

Google 示例最能说明问题:

https://developers.google.com/youtube/youtube_player_demo

更改“速率”,您将看到视频速率/速度没有改变。

最佳答案

不确定为什么 setPlaybackRateYouTube Player Demo website 中不起作用,但如果您尝试一下,肯定会奏效。

这是我使用的代码,您可以查看 working jsfiddle :

// 2. This code loads the IFrame Player API code asynchronously.
var tag = document.createElement('script');

tag.src = "https://www.youtube.com/iframe_api";
var firstScriptTag = document.getElementsByTagName('script')[0];
firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);

// 3. This function creates an <iframe> (and YouTube player)
// after the API code downloads.
var player;

function onYouTubeIframeAPIReady() {
player = new YT.Player('player', {
height: '360',
width: '640',
videoId: '00vnln25HBg',
playerVars: {
'autoplay': 1,
'loop': 1,
'mute': 1
},
events: {
'onReady': onPlayerReady,
'onStateChange': onPlayerStateChange
}
});
}

// 4. The API will call this function when the video player is ready.
function onPlayerReady(event) {
event.target.playVideo();
}

// 5. The API calls this function when the player's state changes.
// Here I set the "setPlaybackRate" value to "2".

function onPlayerStateChange(event) {
player.setPlaybackRate(2);
}

function stopVideo() {
player.stopVideo();
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
<div id="player"></div>

关于youtube-iframe-api - YouTube Java Script player.setPlaybackRate() API 不再有效,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54333607/

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