在滚动视图中添加正在运行的视频
我创建了一个 scrollView
并需要向其中添加一些正在运行的视频。 我做了以下事情:
scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)];
scrollView.pagingEnabled = YES;
NSURL *fileUrl1 = [[NSURL alloc] initFileURLWithPath:[[NSBundle mainBundle] pathForResource:@"AUDI_anti_crevaison_1" ofType:@"mp4"]];
NSURL *fileUrl2 = [[NSURL alloc] initFileURLWithPath:[[NSBundle mainBundle] pathForResource:@"AUDI_Utilisation_de_la_roue_de_secours_2" ofType:@"mp4"]];
videoPlayer1 = [[MPMoviePlayerController alloc] initWithContentURL:fileUrl1];
videoPlayer2 = [[MPMoviePlayerController alloc] initWithContentURL:fileUrl2];
[self.scrollView addSubview:videoPlayer1.view];
scrollView.contentSize = CGSizeMake(self.view.frame.size.width *2, self.view.frame.size.height);
[self.view addSubview:scrollView];
[scrollView release];
首先,似乎这一行: [self.scrollView addSubview:videoPlayer1]
已损坏,我无法将 MPMoviePlayer
添加到 UIView
。 其次,如何设置每个视频的帧...xOrigin
和 yOrigin
?
我希望有一个完整的代码,可以将 .mp4 文件添加到 UIScrollView 中,因为我似乎无法使其工作。
谢谢你!:)
I have created a scrollView
and need to add some running videos to it.
I did the following thing:
scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)];
scrollView.pagingEnabled = YES;
NSURL *fileUrl1 = [[NSURL alloc] initFileURLWithPath:[[NSBundle mainBundle] pathForResource:@"AUDI_anti_crevaison_1" ofType:@"mp4"]];
NSURL *fileUrl2 = [[NSURL alloc] initFileURLWithPath:[[NSBundle mainBundle] pathForResource:@"AUDI_Utilisation_de_la_roue_de_secours_2" ofType:@"mp4"]];
videoPlayer1 = [[MPMoviePlayerController alloc] initWithContentURL:fileUrl1];
videoPlayer2 = [[MPMoviePlayerController alloc] initWithContentURL:fileUrl2];
[self.scrollView addSubview:videoPlayer1.view];
scrollView.contentSize = CGSizeMake(self.view.frame.size.width *2, self.view.frame.size.height);
[self.view addSubview:scrollView];
[scrollView release];
First of all, it seems this line: [self.scrollView addSubview:videoPlayer1]
is broken, I cannot add MPMoviePlayer
to a UIView
.
And second how can I set the frame for each video...the xOrigin
and yOrigin
?
I would appreciate a complete code with adding .mp4
files to a UIScrollView
cause I cannot seem to make it work.
Thank you!:)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
不起作用。我发现您有 Android 经验 - 这就像 Android 上的 Activity 和 View 之间的区别。
doesn't work. I see that you have Android experience - it's like the difference between activity and view on android