【问题标题】:Ionic unable to mute html5 video on iOSIonic 无法在 iOS 上静音 html5 视频
【发布时间】:2016-12-09 05:59:54
【问题描述】:

我正在尝试在 Ionic 1.3 / iOS 10 上静音 html5 视频,但到目前为止,该视频仍以等于 1 的音量播放。这是我的 HTML

  <video muted="muted" preload="metadata" x-webkit-airplay="allow" webkit-playsinline="webkit-playsinline" class="videoPlayer" on-tap="onTap(1)">
      <source src="video/article1.mp4" type="video/mp4"/>
  </video>

我知道 muted 属性在 iOS 10 上不起作用,这就是为什么我使用 JS 将音量设置为 cero 但在 iOS 上仍然不起作用,因为它在浏览器中起作用

var video = $('.videoPlayer');
video.each(function(i){
    $(this).get(0).volume // returns 1
    $(this).get(0).volume = 0 // returns 0 in the browser but 1 on iOS
});

知道为什么这不起作用吗?

另一方面,我也尝试使用 cordova-plugin-media,但它似乎不适用于 mp4 文件。谢谢

【问题讨论】:

标签: javascript html video ionic-framework


【解决方案1】:
@ViewChild('videoSelector', { static: false, read: ElementRef }) videoElement: ElementRef;

  ngAfterViewInit() {

this.videoElement.nativeElement.muted = true;

} }

【讨论】:

  • 请不要只发布代码作为答案,还要解释您的代码的作用以及它如何解决问题的问题。带有解释的答案通常更有帮助,质量更高,更有可能吸引投票。
猜你喜欢
  • 2015-04-29
  • 1970-01-01
  • 2020-10-01
  • 2018-09-26
  • 2019-12-14
  • 1970-01-01
  • 1970-01-01
  • 2019-09-21
  • 1970-01-01
相关资源
最近更新 更多