美文网首页
AVPlayer 和 AVPlayerViewControlle

AVPlayer 和 AVPlayerViewControlle

作者: 冰天无幻 | 来源:发表于2019-12-24 14:20 被阅读0次

检查当前手机是否在禁音模式下,左上角音量键上面那个按钮是否拨在下面。

如果是在下面没有声音在上面有声音而在上面有声音那么请继续往下看

AppDelegate.m 上加上下面方法则就有声音了

- (BOOL)application:(UIApplication*)applicationdidFinishLaunchingWithOptions:(NSDictionary*)launchOptions {

//加入下面3句代码。

{

 AVAudioSession* avSession = [AVAudioSession sharedInstance];

    [avSessionsetCategory:AVAudioSessionCategoryPlayback error:nil];

    [avSessionsetActive:YESerror:nil];

}

}

用户有时会在静音模式下观看视频,如果不主动设置的话,视频是没有声音的,通过AVAudioSession可开启以视频为主导的播放模式,

首先需要导入,AVFoundtion.framework,在控制播放的Controller里面,需要导入<AVFoundtion/AVFoundtion.h>文件

相关文章

网友评论

      本文标题:AVPlayer 和 AVPlayerViewControlle

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