在另一个视图中打开电影流

发布于 2024-12-06 02:38:38 字数 524 浏览 0 评论 0原文

我的应用程序中有一个包含许多选项卡的选项卡视图,其中一个选项卡中有一个按钮,单击该按钮时,我想在视图中显示电影流。我有这样的代码:

NSString *moviePath = @"http://10.0.0.4/prog_index.m3u8";

theMovie = [[MPMoviePlayerController alloc] initWithContentURL:[NSURL URLWithString:moviePath]];

[theMovie.view setFrame:CGRectMake(0, 0, (self.view.frame.size.width), (self.view.frame.size.height))];

theMovie.view.backgroundColor = [UIColor grayColor];
theMovie.view.tag = 9999;

[self.view addSubview:[theMovie view]];

[theMovie play];

视图出现,但视频没有开始。怎么了?

I have in my app a tab view with many tabs, and in one of them I have a button that when is clicked, I want to show a movie stream in a view. I have this code:

NSString *moviePath = @"http://10.0.0.4/prog_index.m3u8";

theMovie = [[MPMoviePlayerController alloc] initWithContentURL:[NSURL URLWithString:moviePath]];

[theMovie.view setFrame:CGRectMake(0, 0, (self.view.frame.size.width), (self.view.frame.size.height))];

theMovie.view.backgroundColor = [UIColor grayColor];
theMovie.view.tag = 9999;

[self.view addSubview:[theMovie view]];

[theMovie play];

The view appears, but the video doesn't start. What is wrong?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

风和你 2024-12-13 02:38:38

您正在向 MPMoviePlayerController 传递一个指向 m3u8 文件的 URL。那是一个播放列表。要使用 MPMoviePlayerController 播放媒体,您必须将其设置为实际的视频文件。您应该解析播放列表以获取真实视频的链接,然后使用真实链接初始化 MPMoviePlayerController

检查M3U - 维基百科MPMoviePlayerController 参考

另请检查此相关问题

编辑:感谢雨果·席尔瓦,我意识到MPMoviePlayerController 能够播放m3u8格式的直播流,由于我没有发现您的代码有任何问题,我建议您检查是否是您的流的问题。尝试使用 Apple 提供的示例之一。另请确保您的流满足 Apple 对 HTTP 流

You're passing to the MPMoviePlayerController an URL pointing to a m3u8 file. That is a playlist. To play media with MPMoviePlayerController, you have to set it an actual video file. You should parse the playlist to get the link to the real video and then init your MPMoviePlayerController with the real link.

Check M3U - Wikipedia and MPMoviePlayerController reference

Also check this related question

EDIT: Thanks to Hugo Silva, I realized that MPMoviePlayerController is able to play live streams in m3u8 format, since I've not seen anything wrong in your code, I suggest you to check if it's a problem of your stream. Try using one of the samples provided by Apple. Also make sure that your stream meets Apple's requirements for HTTP Streaming

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文