在滚动视图中添加正在运行的视频

发布于 2024-12-09 14:04:31 字数 1207 浏览 0 评论 0原文

我创建了一个 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。 其次,如何设置每个视频的帧...xOriginyOrigin

我希望有一个完整的代码,可以将 .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 技术交流群。

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

发布评论

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

评论(1

一萌ing 2024-12-16 14:04:31
  • 您应该首先阅读文档
  • 您正在尝试添加控制器而不是视图,这就是它的原因
    不起作用。我发现您有 Android 经验 - 这就像 Android 上的 Activity 和 View 之间的区别。
  • 如果您仍然无法弄清楚,网上有很多用于将视频添加到视图的代码,只需搜索即可。认为没有必要在这里添加这样的通用代码。
  • You should read the documentation first.
  • You're trying to add a controller instead of a view that's why it
    doesn't work. I see that you have Android experience - it's like the difference between activity and view on android
  • If you still can't figure it out there's a lot of code for adding videos to views on the web, just search it. Don't see it necessary to add here such a generic code.
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文