Youtube API setvolume无法在iOS上运行? [英] Youtube API setvolume not working on iOS?

查看:109
本文介绍了Youtube API setvolume无法在iOS上运行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经使用 youtube开发者网站上的iframe API在网页中构建了一个无边框的youtube播放器.一切都像灵符一样,除了当我在iPad或Android设备上查看页面时,视频的音量和静音控件均不起作用.

I have built a chromeless youtube player in a webpage, using the iframe API from the youtube dev site. Everything works like a charm, except when I view my page on an iPad or Android device, the video's volume and mute controls do not work.

_player.mute()
_player.setVolume(0);

奇怪的是,其他控件确实起作用,例如:

Strangely, the other controls DO work, for example:

_player.pauseVideo();
_player.playVideo();

推荐答案

它有效,您只需要在播放器准备就绪并运行后运行它即可.

It works, you just need to run it after player is ready and functioning.

但是在移动设备上,音量取决于设备本身的设置,而不取决于播放器.因此setVolume没有任何作用.

But on mobile devices, volume depends on the device's own setting rather than the player. So setVolume doesn't have any effect.

这里是一个示例: http://jsfiddle.net/iulukaya/XQ4bz/

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

var player; function onYouTubeIframeAPIReady() {
    player = new YT.Player('player', {
        height: '250',
        width: '444',
    videoId: 'M7lc1UVf-VE',
    events: {
      'onReady': onPlayerReady
    }   }); }

function onPlayerReady(event) {
    event.target.playVideo();
    event.target.setVolume(0); }

这篇关于Youtube API setvolume无法在iOS上运行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆