如何使MPMoviePlayerController忽略静音开关 [英] How to make MPMoviePlayerController ignore the mute switch

查看:144
本文介绍了如何使MPMoviePlayerController忽略静音开关的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用 MPMoviePlayerController 播放视频,但我希望它忽略静音开关,类似于Youtube视频播放器的行为。

I want to play a video using MPMoviePlayerController but I want it to ignore the mute switch, similar to the behavior of Youtube's video player.

任何想法?

推荐答案

使用 AVAudioSession 类别 AVAudioSessionCategoryPlayback ,您的应用将忽略Youtube应用程序之类的静音开关。

Use the AVAudioSession category AVAudioSessionCategoryPlayback and your app will ignore the mute switch like the Youtube app.

例如(受启发者Ken Pletzer在评论中):

For example (inspired by Ken Pletzer in the comments):

#import <AVFoundation/AVFoundation.h>

// note: you also need to add AVfoundation.framework to your project's 
// list of linked frameworks
NSError *error = nil;
BOOL success = [[AVAudioSession sharedInstance] 
                setCategory:AVAudioSessionCategoryPlayback 
                error:&error];
if (!success) {
    // Handle error here, as appropriate
}

这篇关于如何使MPMoviePlayerController忽略静音开关的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆