【发布时间】:2016-04-11 11:31:07
【问题描述】:
我正在开发 iOS 应用程序的直播功能。我使用了一个包含在 ContainerView 中的 AVPlayerViewController 来显示视频。
这里是 ViewController 的相关代码
@interface ViewController ()
@property MPMoviePlayerController* streamPlayer;
@property BOOL isPlaying;
@end
AVPlayerViewController *streamPlayer;
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
self.isPlaying = NO;
NSURL *streamURL = [NSURL URLWithString:@"http://vevoplaylist-live.hls.adaptive.level3.net/vevo/ch1/appleman.m3u8"];
streamPlayer = [[ UIStoryboard storyboardWithName:@"Main" bundle:nil] instantiateViewControllerWithIdentifier:@"StreamPlayer" ];
streamPlayer.player = [ AVPlayer playerWithURL:streamURL ];
}
- (IBAction)playVideo:(id)sender{
if ( !self.isPlaying ){
[ streamPlayer.player play ];
[self.button setTitle:@"Stop" forState:UIControlStateNormal ];
self.isPlaying = YES;
} else {
[ streamPlayer.player pause ];
[self.button setTitle:@"Play" forState:UIControlStateNormal ];
self.isPlaying = NO;
}
}
(你可以忽略isPlaying变量,只是看看我能控制什么)
流开始并正常工作几分钟,然后停止/缓冲(我认为)几秒钟并出现错误:
ERROR: 849: AudioQueue: request to trim 4291961269 + 0 = 4291961269 frames from buffer containing 21504 frames
在此之后流继续,但没有音频。
偶尔会有一两秒钟的音频,但立即再次出现错误,并且流在静默中继续。 (当 Pitbull 视频正在播放时,我很高兴。)
如果我暂停流然后播放它,音频会返回几分钟,然后再次关闭。
我已经搜索过这个错误,但没有找到任何可以帮助我解决这个问题的东西。作为 iOS 和 HLS 的新手,我不知道可能是什么问题,但如果我不得不猜测,我会说这是音频和视频同步的问题。
感谢任何和所有的帮助。
【问题讨论】:
标签: ios objective-c iphone audio http-live-streaming