如何快速在 uiwebview 中设置音量? [英] How can i volume set in uiwebview with swift?

查看:55
本文介绍了如何快速在 uiwebview 中设置音量?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用 YouTube iFrame 播放视频.完美关闭了 webview 中的 youtube 控件.player.playVideo(),player.stopVideo() 工作但 player.mute() 和 player.Setvolume (60) 没有.有人帮我吗?我正在使用这个模块 https://github.com/gilesvangruisen/Swift-YouTube-Player/

I play video using YouTube iFrame. Closed youtube controls in webview perfectly. player.playVideo(),player.stopVideo() working but player.mute() and player.Setvolume (60) does not. does anyone help me? i am using this module https://github.com/gilesvangruisen/Swift-YouTube-Player/

推荐答案

YouTube Api

大多数 JavaScript 播放器 API 函数都具有 Objective-C 等效项,但某些命名可能略有不同,以更接近于 Objective-C 编码指南.值得注意的例外是控制视频音量的方法,因为这些方法由手机硬件或为此目的设计的内置 UIView 实例(例如 MPVolumeView)控制.

Most of the JavaScript Player API functions have Objective-C equivalents, though some of the naming may differ slightly to more closely match Objective-C coding guidelines. Notable exceptions are methods controlling the volume of the video, since these are controlled by the phone hardware or with built in UIView instances designed for this purpose, such as MPVolumeView.

https://developer.apple.com/library/safari/documentation/AudioVideo/Conceptual/Using_HTML5_Audio_Video/Device-SpecificConsiderations/Device-SpecificConsiderations.html#//apple_ref/doc/uid/TP40009523-CH5-SW10

JavaScript 中的音量控制

Volume Control in JavaScript

在桌面上,您可以设置和读取或元素的音量属性.这允许您相对于计算机的当前音量设置设置元素的音频音量.值为 1 时以正常级别播放声音.值为 0 会使音频静音.0 到 1 之间的值会衰减音频.这种音量调节很有用,因为它允许用户将游戏静音,例如,同时仍然在计算机上听音乐.在 iOS 设备上,音频电平始终在用户的物理控制之下.音量属性在 JavaScript 中不可设置.读取 volume 属性总是返回 1.

On the desktop, you can set and read the volume property of an or element. This allows you to set the element’s audio volume relative to the computer’s current volume setting. A value of 1 plays sound at the normal level. A value of 0 silences the audio. Values between 0 and 1 attenuate the audio. This volume adjustment can be useful, because it allows the user to mute a game, for example, while still listening to music on the computer. On iOS devices, the audio level is always under the user’s physical control. The volume property is not settable in JavaScript. Reading the volume property always returns 1.

这篇关于如何快速在 uiwebview 中设置音量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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