[英]MPMoviePlayer audio breaking issue
我正在應用中的MPMoviePlayer中播放視頻,我正在從服務器中獲取視頻。 如果視頻長度約為25秒或更長,則音頻會中斷。這意味着在播放視頻時,如果達到一半,則聽不到聲音。但是,如果我搜索進度條,則會再次出現音頻。
有人可以幫我嗎?
moviePlayerController = [[MPMoviePlayerController alloc] init];
[moviePlayerController prepareToPlay];
moviePlayerController.shouldAutoplay = YES;
[moviePlayerController setScalingMode:MPMovieScalingModeAspectFit];
[[self.moviePlayerController view] setFrame:CGRectMake(0, 72, 320,180)];
[[self view] addSubview: [self.moviePlayerController view]];
self.moviePlayerController.useApplicationAudioSession = YES;
NSString *strng = @"http://qdemo_videos.s3.amazonaws.com/1360582540.mp4";
NSURL * adurl = [NSURL URLWithString:strng];
moviePlayerController.contentURL = url;
moviePlayerController.controlStyle = YES;
self.moviePlayerController.useApplicationAudioSession = YES;
[moviePlayerController play];
如果您使用Xcode 4.6或更高版本並使用iOS 6.0或更高版本,
self.moviePlayerController.useApplicationAudioSession = YES;
不會被視為不推薦使用。
要進一步使用此鏈接,請執行以下操作:這是文檔http://developer.apple.com/library/ios/#documentation/AVFoundation/Reference/AVAudioSession_ClassReference/Reference/Reference.html
就我而言,將類別設置為AVAudioSessionCategoryAmbient可以解決問題!
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.