是否可以通过 url 同时播放 2 个视频

发布于 2024-10-17 17:53:22 字数 638 浏览 1 评论 0原文

在开始我的任务之前,我想知道使用 url 同时(一起)播放 2 个视频的可能性。

我尝试在部分屏幕中播放视频的代码:

player = [[MPMoviePlayerController alloc] initWithContentURL:[self movieURL]];
player.view.frame = CGRectMake(100, 150, 250, 300);
[self.view addSubview:player.view];
[[NSNotificationCenter defaultCenter]addObserver:self
                                        selector:@selector(movieFinishedCallback:)
                                            name:MPMoviePlayerPlaybackDidFinishNotification
                                          object:player];
[player play];

错误:错误:请求成员“查看”不是结构或联合的东西

任何人都帮帮我...

Before start my task i want to know the possibilities for playing 2 videos simultaneously(together) by using url.

Code that i'm tried for play the video in a partial screen:

player = [[MPMoviePlayerController alloc] initWithContentURL:[self movieURL]];
player.view.frame = CGRectMake(100, 150, 250, 300);
[self.view addSubview:player.view];
[[NSNotificationCenter defaultCenter]addObserver:self
                                        selector:@selector(movieFinishedCallback:)
                                            name:MPMoviePlayerPlaybackDidFinishNotification
                                          object:player];
[player play];

Error: error:request for member 'view' in somthing not a structure or union

Anyone Helpme...

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

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

发布评论

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

评论(2

荒岛晴空 2024-10-24 17:53:22

正常情况下不会。 MPMoviePlayerController 通过连接到一个单独的服务器进程来工作,该进程执行实际的视频解压缩。它一次只解压缩一个流,因此一次只有一个电影视图可以播放内容。

最好的选择是使用您最喜欢的视频编辑软件将两部电影并排合并为一部电影。显然,如果您想单独播放/暂停/快退它们,这并不好。或者,如果其中一部电影非常小,请将其转换为静止帧并使用 UIImageView 的多图像动画功能。不过,从远程 URL 播放 h.264 是完全可行的。

[编辑添加:]

iOS 3.x 确实如此,但 iOS 4 及更高版本在 AVFoundation 中提供视频支持,特别是 AVPlayer 和 AVPlayerLayer 类。如果您使用它们来构建电影视图,则可以同时独立地观看多个电影视图。您没有得到的是库存 MPMoviePlayerController 传输控件(播放/暂停/滑动条);对于 AVFoundation,如果你想要类似的东西,你必须自己推出。

Not normally. MPMoviePlayerController works by connecting to a separate server process, which does the actual video decompression. It only decompresses one stream at a time, so only one movie view can have playing content at once.

Your best bet is to use your favorite video editing software to combine both movies into a single movie, side by side. Obviously this is no good if you want to play/pause/rewind them separately. Or, if one of the movies is very small, convert it to still frames and use UIImageView's multi-image animation feature. Playing h.264 from a remote URL is right out, though.

[Edited to add:]

This was true for iOS 3.x, but iOS 4 and later have video support in AVFoundation, specifically, the AVPlayer and AVPlayerLayer classes. If you use them to construct movie views, you can have more than one going at once, independently. What you don't get are the stock MPMoviePlayerController transport controls (play/pause/scrub bar); with AVFoundation you have to roll your own if you want something similar.

潦草背影 2024-10-24 17:53:22

是的,当然,您可以同时播放两个视频,甚至可以相互播放

查看此网址 &得到一个想法。

Yeah sure, you can play two videos simultaneaously, even on each other

Checkout this url & get an idea.

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