ios - 如何让MPMoviePlayerController忽略静音开关

标签 ios iphone mpmovieplayercontroller avaudiosession

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

有什么想法吗?

最佳答案

使用 AVAudioSession 类别 AVAudioSessionCategoryPlayback,您的应用将像 Youtube 应用一样忽略静音开关。

例如(灵感来自评论中的 Ken Pletzer):

#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
}

关于ios - 如何让MPMoviePlayerController忽略静音开关,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4388801/

相关文章:

ios - 在 Swift 中使用更新函数的更清洁(更好)替代方法

ios - 带有推送通知的应用提交到应用商店

iphone - 如何计算一个页面的 facebook "likes"和 facebook "people talking about"?

iphone - MOV 播放无法使用带有 MPMoviePlayerController 的 UIImagePickerController

iphone - UIMoviePlayerController ... 可以用吗?

ios - UILabel 图层背景色部分填充意外

ios - 流畅的自转动画

ios - 裁剪图像的图像裁剪问题

iphone - UITableView 内容 "Static cell"在 iOS7 中不起作用

iphone - 播放 YouTube 后 MPMoviePlayerController 问题