美文网首页ios 知识点
视频静音的方法

视频静音的方法

作者: 小曼blog | 来源:发表于2017-12-20 11:20 被阅读4次

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

    在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;

    相关文章

      网友评论

        本文标题:视频静音的方法

        本文链接:https://www.haomeiwen.com/subject/ycfgwxtx.html