简体   繁体   English

Ionic 无法在 iOS 上静音 html5 视频

[英]Ionic unable to mute html5 video on iOS

I am trying to mute a html5 video on Ionic 1.3 / iOS 10 but so far the video still play with volume equals to 1. This is my HTML我试图在 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>

I understand the muted attribute doesn't work on iOS 10 what's why I used JS to set the volume to cero but still doesn't work on iOS thought it works in the browser我知道 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
});

Any idea why this isn't working?知道为什么这不起作用吗?

On the other hand I also tried to use cordova-plugin-media but it seems not to be working with mp4 files.另一方面,我也尝试使用 cordova-plugin-media 但它似乎不适用于 mp4 文件。 Thanks谢谢

@ViewChild('videoSelector', { static: false, read: ElementRef }) videoElement: ElementRef;

  ngAfterViewInit() {

this.videoElement.nativeElement.muted = true;

} } } }

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

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