简体   繁体   English

Cordova iOS 音频和视频标签的静音属性不起作用?

[英]Cordova iOS audio and video tag's muted attribute not working?

We have a Cordova app that renders an HTML page that uses audio and video HTML tags for streaming audio and video.我们有一个 Cordova 应用程序,它呈现一个 HTML 页面,该页面使用音频和视频 HTML 标签来流式传输音频和视频。

Setting the muted attribute on these tags has no effect (always hear the sound) when rendering this page in Cordova.在 Cordova 中呈现此页面时,在这些标签上设置静音属性没有任何效果(总是听到声音)。

If I render the same page in Safari (on the same iOS device) the muted attribute works as expected.如果我在 Safari (在同一个 iOS 设备上)呈现相同的页面,则 muted 属性按预期工作。

Anyone have any insight as to why muted doesn't work in Cordova?任何人都知道为什么静音在 Cordova 中不起作用? Known issue?已知问题? Maybe a Webkit issue?也许是 Webkit 问题?

Turns out iosrtc was "getting in way".原来 iosrtc 正在“阻碍”。 I ended up disabling the audio track instead of muting the html tag.我最终禁用了音轨,而不是使 html 标签静音。

The iosrtc plugin render the video as a "mock" html element. iosrtc 插件将视频渲染为“模拟” html 元素。 Not real html element.不是真正的 html 元件。 So every time changes made on that element, you need to refresh it natively using cordova.plugins.iosrtc.refreshVideos() function.因此,每次对该元素进行更改时,您都需要使用cordova.plugins.iosrtc.refreshVideos() function 本地刷新它。 This function will send command to native codes to refresh new attribute or changes on the UIView in native.此 function 将向本地代码发送命令以刷新本地UIView的新属性或更改。

Here's some example I used before:这是我之前使用的一些示例:

$(".muted-btn").on("click", function(){
   $("video").prop("muted", true);
   cordova.plugins.iosrtc.refreshVideos();
});

Even if you navigate to another page, the video element will stick to your view if you are not refreshing the UIView using the refreshVideos() function.即使您导航到另一个页面,如果您不使用refreshVideos() function 刷新UIView ,则视频元素仍将停留在您的视图中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM