简体   繁体   English

在iOS中播放.mov文件

[英]playing .mov files in iOS

So I am trying to play an intro scene in the format of a .mov file in my iOS (cocos2d) game. 因此,我尝试在iOS(cocos2d)游戏中以.mov文件的格式播放介绍性场景。

This is my current code. 这是我当前的代码。

CGSize winSize = [[CCDirector sharedDirector] winSize];

    NSURL *url = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"DD Logo" ofType:@"mov"]];
    MPMoviePlayerController * mpc;
    mpc = [[MPMoviePlayerController alloc] initWithContentURL:url];
    [mpc setFullscreen:YES animated:NO];
    mpc.shouldAutoplay = YES;
    mpc.view.backgroundColor = [UIColor whiteColor];
    mpc.view.frame = CGRectMake(0.0f, 0.0f, winSize.width, winSize.height);

    [mpc setScalingMode:MPMovieScalingModeFill];
    [mpc setControlStyle:MPMovieControlStyleNone];
    [mpc setMovieSourceType:MPMovieSourceTypeFile];
    [mpc setRepeatMode:MPMovieRepeatModeNone];

    [[[CCDirector sharedDirector] openGLView] addSubview:mpc.view];

    [mpc play];

What happens is, the audio plays, but this is what the screen looks like. 发生的是,音频在播放,但这就是屏幕的样子。 http://gyazo.com/4f046472666bf1f58c88128f24e66229 http://gyazo.com/4f046472666bf1f58c88128f24e66229

Check out this git project, 看看这个git项目,

Open source library called Cocos2D extensions that includes a class you can use to play videos in Cocos2D. 名为Cocos2D扩展的开放源代码库,其中包含可用于在Cocos2D中播放视频的类。

https://github.com/cocos2d/cocos2d-iphone-extensions https://github.com/cocos2d/cocos2d-iphone-extensions

if thats too old what about this 如果那太旧了,那该怎么办

[CCVideoPlayer setDelegate: self]; [CCVideoPlayer setDelegate:self]; [CCVideoPlayer playMovieWithFile: @"movie.m4v"]; [CCVideoPlayer playMovieWithFile:@“ movie.m4v”];

or this... 或这个...

http://pskfire.iteye.com/blog/1680123 http://pskfire.iteye.com/blog/1680123

Sometimes I have issues playing .mov files. 有时我在播放.mov文件时遇到问题。 For me when I change to mp4, it works. 对我来说,当我更改为mp4时,它可以工作。 Your code looks right so maybe changing the format would help? 您的代码看起来正确,因此也许更改格式会有所帮助? It is possible the codec being used in the .mov is not iOS compatible. .mov中使用的编解码器可能与iOS不兼容。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM