gpt4 book ai didi

iphone - MPMoviePlayer 音频中断问题

转载 作者:行者123 更新时间:2023-11-28 17:54:46 25 4
gpt4 key购买 nike

我正在我的应用程序中的 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

这是解释http://developer.apple.com/library/ios/#documentation/Audio/Conceptual/AudioSessionProgrammingGuide/Configuration/Configuration.html

如果还不够,这里是代码:) http://developer.apple.com/library/ios/#documentation/Audio/Conceptual/AudioSessionProgrammingGuide/Cookbook/Cookbook.html#//apple_ref/doc/uid/TP40007875-CH6-SW2

在我的例子中,将类别设置为 AVAudioSessionCategoryAmbient 就成功了!

关于iphone - MPMoviePlayer 音频中断问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15067394/

25 4 0
文章推荐: javascript - 解析 Peg.JS 中的段落
文章推荐: html - 让
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com