playing .mov files in iOS

1k Views Asked by At

So I am trying to play an intro scene in the format of a .mov file in my iOS (cocos2d) game.

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

2

There are 2 best solutions below

7
On

Sometimes I have issues playing .mov files. For me when I change to mp4, it works. 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.

1
On

Check out this git project,

Open source library called Cocos2D extensions that includes a class you can use to play videos in Cocos2D.

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

if thats too old what about this

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

or this...

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