视频静音的方法

所谓静音,就是没有声音,把音量调到最小不就好了。所以,只要调节音量就行。那么,这样就很简单了,系统给我们提供了属性啊。

在AVPlayer中,有属性

@property (nonatomic) float volume NS_AVAILABLE(10_7, 7_0);

看注释:

/* Indicates the current audio volume of the player; 0.0 means "silence all audio", 1.0 means "play at the full volume of the current item".

   iOS note: Do not use this property to implement a volume slider for media playback. For that purpose, use MPVolumeView, which is customizable in appearance and provides standard media playback behaviors that users expect.
   This property is most useful on iOS to control the volume of the AVPlayer relative to other audio output, not for volume control by end users. */

所以:

关: self.avPlayer.volume = 0.0;
开: self.avPlayer.volume = 1.0;

©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容