gpt4 book ai didi

ios - MPMoviePlayerController 和基于 Auth 的 HLS 后端服务器

转载 作者:可可西里 更新时间:2023-11-01 04:50:28 26 4
gpt4 key购买 nike

我目前正在使用 MPMoviePlayerController 在我的 iOS 应用程序中提供视频服务。这些文件是从我们需要身份验证的后端服务器流式传输的。它是授权 HTTP header 中基于 key 的身份验证集。

它曾经完美地处理单个视频文件。现在我们正在尝试实现 HLS 自适应流,但我们遇到了障碍。我目前正在使用自定义 NSURLProtocol 子类来捕获对我们的后端服务器发出的请求并注入(inject)正确的 Authorization header 。对于 HLS,它根本不起作用。

当我们查看服务器日志时,我们清楚地看到对 m3u8 文件的第一次请求工作正常。然后所有后续调用(其他 m3u8 文件和 ts 也)被 403 禁止。似乎 MPMoviePlayerController 没有为其他文件使用 NSURLProtocol。 (旁注:它确实适用于模拟器思想,但不适用于物理设备,这让我认为两者的实现方式不同)。

MPMoviePlayerController实例化

self.videoController = [[MPMoviePlayerController alloc] initWithContentURL:video.videoURL];

URL协议(protocol)拦截

+ (NSURLRequest *) canonicalRequestForRequest:(NSURLRequest *)request {
NSMutableURLRequest *newRequest = request.mutableCopy;
[newRequest setValue:@"HIDDEN" forHTTPHeaderField:@"Authorization"];
return newRequest;
}

有什么想法、建议、解决方法吗?

最佳答案

在与 Apple Developer Technical Support 核实后,我认为我想要实现的目标是不可能的(并且不受支持)。

以下是回复中的引述:

The problem you're seeing with NSURLProtocol and so on is that the movie playback subsystem does not run its HTTP requests within your process. Rather, these requests are run from within a separate system process, mediaserverd. Thus, all your efforts to affect the behaviour of that playback are futile.

关于ios - MPMoviePlayerController 和基于 Auth 的 HLS 后端服务器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35926426/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com