是否可以在同一视图中同时播放 2 个视频文件?

发布于 2024-10-18 16:08:15 字数 352 浏览 0 评论 0原文

是否可以在同一视图中同时播放 2 个视频文件?

我想让它们都在屏幕的一半以上播放,有点像这样:

 _ _ _ _ _ _ _ _ _ _ 
|                   |
|                   |
|       VIDEO       |
|                   |
|_ _ _ _ _ _ _ _ _ _|
|                   |
|                   |
|      VIDEO        | 
|                   |
|_ _ _ _ _ _ _ _ _ _|

我将如何实现这一目标?

谢谢 :)

Is it possible to play 2 video files simultaneously in the same view?

I want to do have them both playing over half the screen, a little like this:

 _ _ _ _ _ _ _ _ _ _ 
|                   |
|                   |
|       VIDEO       |
|                   |
|_ _ _ _ _ _ _ _ _ _|
|                   |
|                   |
|      VIDEO        | 
|                   |
|_ _ _ _ _ _ _ _ _ _|

How would I go about accomplishing this?

Thanks :)

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

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

发布评论

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

评论(3

雨落星ぅ辰 2024-10-25 16:08:15

苹果的文档说:

虽然你可以创建多个MPMoviePlayerController对象并在你的界面中呈现它们的视图,但一次只能有一个电影播放器​​可以播放它的电影。

所以,你知道...

apple's document said:

Although you may create multiple MPMoviePlayerController objects and present their views in your interface, only one movie player at a time may play its movie.

so,you know...

空心↖ 2024-10-25 16:08:15

一次播放 2 个视频是可能的。

步骤:

1.创建 2 个 MPMoviePlayer 实例

2.使用 CGRectMake 为 2 个播放器设置帧

3.将 2 个播放器添加到视图(self.view)

I希望以上步骤对您有帮助。

播放器设置框架仅支持 iOS 3.2 及以上版本。

如果您有任何疑问,请告诉我。

示例代码:

player1.view.frame = CGRectMake(0, 0, 320, 240);
[self.view addSubview:player1.view];
[[NSNotificationCenter defaultCenter]addObserver:self 
                                        selector:@selector(movieFinishedCallback:)
                                            name:MPMoviePlayerPlaybackDidFinishNotification
                                          object:player1];
[player1 play];
player2.view.frame = CGRectMake(0, 241, 320, 220);
[self.view addSubview:player2.view];
[[NSNotificationCenter defaultCenter]addObserver:self 
                                        selector:@selector(movieFinishedCallback:)
                                            name:MPMoviePlayerPlaybackDidFinishNotification
                                          object:player2];
[player2 play];

Play 2 video's at a time is possible..

STEPS:

1.create 2 instance of MPMoviePlayer

2.set frame for 2 player by using CGRectMake

3.Add 2 players to the view(self.view)

I hope above steps are helpful for u.

setting frame for player only supported in iOS 3.2 and above versions.

Let me know you have any doubt.

Sample Code:

player1.view.frame = CGRectMake(0, 0, 320, 240);
[self.view addSubview:player1.view];
[[NSNotificationCenter defaultCenter]addObserver:self 
                                        selector:@selector(movieFinishedCallback:)
                                            name:MPMoviePlayerPlaybackDidFinishNotification
                                          object:player1];
[player1 play];
player2.view.frame = CGRectMake(0, 241, 320, 220);
[self.view addSubview:player2.view];
[[NSNotificationCenter defaultCenter]addObserver:self 
                                        selector:@selector(movieFinishedCallback:)
                                            name:MPMoviePlayerPlaybackDidFinishNotification
                                          object:player2];
[player2 play];
伤痕我心 2024-10-25 16:08:15

您可以使用AVPlayer同时播放两个视频,查看Layer的帧即可获得所需的帧请按照以下链接< /a>.

You can use AVPlayer to play two video simultaneously seeting frame of Layer you can get the required frame Please follow following link.

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