views:

5130

answers:

3

Hi, I am trying to play video inside a UIView, so my first step was to add a class for that view and start playing a movie in it using this code:

- (IBAction)movie:(id)sender{
    NSBundle *bundle = [NSBundle mainBundle];
     NSString *moviePath = [bundle pathForResource:@"Movie" ofType:@"m4v"];
    NSURL *movieURL = [[NSURL fileURLWithPath:moviePath] retain];
    MPMoviePlayerController *theMovie = [[MPMoviePlayerController alloc] initWithContentURL:movieURL];
    theMovie.scalingMode = MPMovieScalingModeAspectFill;
    [theMovie play];
}

But this just crashes the app when using this method inside it's own class, but is fine elsewhere. Does anyone know how to play video inside a view? and avoid it being full screen?

+2  A: 

You cannot play a video inside a view. It has to be played fullscreen.

zPesk
Ok, well that's a shame, but I have seen other apps on the appstore where video has been played not full screen but in a smaller view inside the main screen, so there must be a way.
Jessica
Maybe those examples of video-in-a-view have been sequential images with an extra track of sound.
mga
They likely were. Sadly.
Sneakyness
I think this answer is outdated, as in SDK 3.2, there are clearly partial-screen videos available in apps that can go to fullscreen with user interaction.
Jasconius
I agree! Anyone found out, how to do this?
amok
I've added another answer outlining how you do this in 3.2
half_brick
+3  A: 
half_brick
+1  A: 

Also there is this nice tip:

http://www.nightirion.com/2010/01/scaling-a-movie-on-the-iphone/

LiveMixBox