寻求有关在 iPhone 上播放电影的建议

发布于 2024-10-31 00:51:18 字数 228 浏览 0 评论 0原文

嗨,

我正在寻找一种在我的应用程序中以描绘模式播放电影作为背景的方法。电影不应响应任何点击,我的应用程序将在电影上有自己的按钮和标签来控制应用程序。

如果您碰巧从 iTunes 商店知道 Dragons Lair/Space Ace 应用程序,那么就是这样。

似乎有几种播放 m4v 文件的方法。

有什么建议可以给我提供如上所述的视频播放功能吗?

感谢您的阅读!

Hia,

I'm looking for a way to play a movie as background in portray mode in my app. The movie should not respond to any taps and my app would have its own buttons and labels over the movie that control the app.

If you happens to know the Dragons Lair/Space Ace app from iTunes store, something this way.

It seems there are several approaches for playing a m4v file.

Any suggestion which would give me a video playback like described above?

Thanks for reading!

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

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

发布评论

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

评论(3

━╋う一瞬間旳綻放 2024-11-07 00:51:18

在应用程序委托的 application:didFinishLaunchingWithOptions: 中,您可以使用此代码。技巧是,您仍然必须在视频播放之前显示 Default.png

请务必将 MediaPlayer.framework 添加到您的项目中

NSString *videoUrl = [[NSBundle mainBundle] pathForResource:@"video" ofType:@"mp4"];  
    MPMoviePlayerViewController * movieView;
    movieView = [[MPMoviePlayerViewController alloc] initWithContentURL:[NSURL fileURLWithPath:videoUrl]];

    MPMoviePlayerController * theMovie = [movieView moviePlayer];
    theMovie.scalingMode = MPMovieScalingModeAspectFit;
    theMovie.fullscreen = TRUE;
    theMovie.controlStyle = MPMovieControlStyleNone;
    theMovie.shouldAutoplay = TRUE;    
    [_window addSubview:movieView.view];

In your app delegate, in application:didFinishLaunchingWithOptions: you can use this code. Trick is, you still have to show Default.png before the video plays.

Be sure to add MediaPlayer.framework to your project

NSString *videoUrl = [[NSBundle mainBundle] pathForResource:@"video" ofType:@"mp4"];  
    MPMoviePlayerViewController * movieView;
    movieView = [[MPMoviePlayerViewController alloc] initWithContentURL:[NSURL fileURLWithPath:videoUrl]];

    MPMoviePlayerController * theMovie = [movieView moviePlayer];
    theMovie.scalingMode = MPMovieScalingModeAspectFit;
    theMovie.fullscreen = TRUE;
    theMovie.controlStyle = MPMovieControlStyleNone;
    theMovie.shouldAutoplay = TRUE;    
    [_window addSubview:movieView.view];
自控 2024-11-07 00:51:18

查看 MPMoviePlayerController 的文档。它使您可以访问电影播放器​​视图,您可以任意调整该视图的大小并将其添加到视图层次结构中。类参考文档对此进行了详细解释。

将播放器的 controlStyle 设置为 MPMovieControlStyleNone 以删除播放器控件。

Look at the documentation for MPMoviePlayerController. It gives you access to a movie player view that you can arbitrarily size and add to your view hierarchy. This is explained in detail in the Class Reference documentation.

Set the player's controlStyle to MPMovieControlStyleNone to remove the player controls.

◇流星雨 2024-11-07 00:51:18

Apple 的 MPMoviePlayerController 文档对于这项任务非常有帮助。

将电影播放器​​视图视为
不透明结构。您可以添加自己的
自定义子视图以分层内容
电影的顶部,但你绝对不能
修改其任何现有子视图。

除了在顶部分层内容之外
电影的,您可以提供定制
通过添加子视图来显示背景内容
到后台视图View
财产。 (MPMoviePlayerController 类参考)

文档进一步指出了您所追求的真正的金块:

该类支持编程
控制电影播放,以及
通过按钮进行基于用户的控制
由电影播放器​​提供。你可以
控制播放的大部分方面
以编程方式使用方法和
MPMediaPlayback 的属性
该类遵循的协议

,您可以:

  1. 将 MPMoviePlayerController 的 controlStyle 设置为 'MPMovieControlStyleNone'
  2. 覆盖您自己的视图和控件
    播放器顶部
  3. 控制“播放
    以编程方式使用方法
    和属性”的
    MPMediaPlayback协议

Apple's documentation for MPMoviePlayerController will be very helpful for this task.

Consider a movie player view to be an
opaque structure. You can add your own
custom subviews to layer content on
top of the movie but you must never
modify any of its existing subviews.

In addition to layering content on top
of a movie, you can provide custom
background content by adding subviews
to the view in the backgroundView
property. (MPMoviePlayerController Class Reference)

The docs further note the real nugget you are after:

This class supports programmatic
control of movie playback, and
user-based control via buttons
supplied by the movie player. You can
control most aspects of playback
programmatically using the methods and
properties of the MPMediaPlayback
protocol, to which this class conforms

So, you can:

  1. Set your MPMoviePlayerController's controlStyle to 'MPMovieControlStyleNone'
  2. Overlay your own views and controls
    on top of the player
  3. Control "playback
    programmatically using the methods
    and properties" of the
    MPMediaPlayback protocol
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文