【问题标题】:Error 849 in livestreaming application on iOSiOS 上的直播应用程序出现错误 849
【发布时间】: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


    【解决方案1】:

    您的代码中有两个问题立即突出。

    1. 您有两个 streamPlayer 变量。
    2. AVPlayerViewController 变量应该是一个全局变量

    通过将您的AVPlayerViewController 属性声明作为全局变量放入您的接口扩展中,应该可以解决错误。

    代码如下所示:

    @interface ViewController ()
    
    @property (nonatomic) MPMoviePlayerController *mpStreamPlayer;
    @property (nonatomic) AVPlayerViewController *avStreamPlayer;
    
    @property (nonatomic) BOOL isPlaying;
    
    @end
    
    @implementation ViewController
    
    
    - (void)viewDidLoad ... // continue as expected
    

    我假设它会得到解决的原因是因为this 社区成员遇到了类似的问题,错误 849(他们的代码库是 SWIFT)和答案工作答案。

    【讨论】:

      【解决方案2】:

      这可能与 iOS 9 错误有关,将您的 m3u8 粘贴到 Safari 中,您可能会遇到同样的问题(中间音频中断,音频/视频不同步),您无能为力代码。

      查看一些报告 here,Apple 工程师要求提交错误报告。

      【讨论】:

        猜你喜欢
        • 2015-07-31
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2016-07-15
        • 1970-01-01
        • 1970-01-01
        • 2019-09-21
        相关资源
        最近更新 更多