问题描述
项目 - >
问题 - > 选项 - >矩阵模式(静音按钮出现,但不显示按下时工作)。
说明 - > 我在HTML中没有src的iframe,其隐藏(宽度,高度= 0)。
如果启用了矩阵模式,则此iframe会被URL归结:
Project -> http://codepen.io/urketadic/full/YpLgBX/
Problem -> Options -> Matrix Mode (mute button appears, but doesn't work when pressed).
Description -> I have iframe in the HTML with no src, its hidden (width,height=0).
If Matrix Mode gets enabled however, this iframe gets attributed with URL:
$('#iframe').attr("src","https://www.youtube.com/embed/videoseries?list=PLikZa7q0vpioApkXpyYxsrsng-nIsXBhv&autoplay=1&loop=1");
我还添加了静音按钮,按下时假设更改为取消静音按钮并使视频播放静音在上面的播放列表中:
I have also added mute button that when pressed is suppose to change to unmute button and also silence video playing in the above playlist:
var player;
function onYouTubeIframeAPIReady() {
player = new YT.Player('ytplayer', {
height: '0',
width: '0',
playerVars: {
listType:'playlist',
list: 'https://www.youtube.com/embed/videoseries?list=PLikZa7q0vpioApkXpyYxsrsng-nIsXBhv' } }
)};
$('#unmute').on('click', function() {
$("#unmute").hide();
$("#mute").show();
player.mute();
});
$('#mute').on('click', function() {
$("#mute").hide();
$("#unmute").show();
player.unmute();
});
静音按钮确实更改为取消静音按钮,但播放列表中的视频不会更改。
有谁知道我在这里做错了什么?
编辑:我目前的情况有,是,我只是在点击时禁用src attr并再次将其返回。这并不是完全无声的,因为它会重置歌曲,但是如果我找不到更好的东西,我只需要这样做。
推荐答案
请查看
请注意HTML部分中的此代码:
Please note this code in HTML section:
<div id="player"></div>
<script>
// 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: '0',
width: '0',
playerVars: {
listType:'playlist',
list: 'PLikZa7q0vpioApkXpyYxsrsng-nIsXBhv' }
});
}
</script>
应该是它。
这篇关于Youtube API,静音视频(iframe)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!