如何在iPhone中使用MPMoviePlayerController播放视频?

发布于 2024-09-27 17:32:31 字数 630 浏览 1 评论 0原文

这是我使用 MPMoviePlayerController 加载视频的代码,我的问题是我可以听到视频的声音,但看不到视频。谁能给我解决办法吗!!!

注意:“AddRunningClient 在非零客户端计数上启动设备”当我在控制台中运行我的应用程序时显示此消息,

现在我正在使用 IOS4.1 sdk

   - (void)viewDidLoad {
     [super viewDidLoad];

     NSString *mediaPath = [[[NSBundle mainBundle]resourcePath] stringByAppendingPathComponent:@"understandingoilcost_1500kbps.mov"];

    MPMoviePlayerController *moviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:[NSURL fileURLWithPath:mediaPath]];

    moviePlayer.scalingMode = MPMovieScalingModeAspectFit;

    [moviePlayer play];
}

请帮助我!

谢谢。

This is my code for load the video using MPMoviePlayerController my issue is i can hear the voice of the video but can't see the video. can any one give me the solution!!!

note:"AddRunningClient starting device on non-zero client count" this message is display while i run my application in console

now i'm working IOS4.1 sdk

   - (void)viewDidLoad {
     [super viewDidLoad];

     NSString *mediaPath = [[[NSBundle mainBundle]resourcePath] stringByAppendingPathComponent:@"understandingoilcost_1500kbps.mov"];

    MPMoviePlayerController *moviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:[NSURL fileURLWithPath:mediaPath]];

    moviePlayer.scalingMode = MPMovieScalingModeAspectFit;

    [moviePlayer play];
}

Please help me out!

Thanks.

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

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

发布评论

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

评论(1

冷弦 2024-10-04 17:32:31

那是因为您还没有将玩家的视图添加到您的视图中。您需要执行以下操作:

[[moviePlayer view] setFrame:[[self view] bounds]];
[[self view] addSubview: [moviePlayer view]];

此外,您应该将电影播放器​​存储在实例变量中,否则您将无法停止或释放它(从而造成内存泄漏)。

That's because you haven't added the player's view to your view. You need to do something like this:

[[moviePlayer view] setFrame:[[self view] bounds]];
[[self view] addSubview: [moviePlayer view]];

Also, you should store the movie player in an instance variable, or else you won't be able to stop it or release it (thus creating a memory leak).

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