Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

gizabo

macrumors regular
Original poster
Jul 20, 2008
124
0
For some reason when I run my code, i get this error

Code:
[UIViewController playVideoWithControls]: unrecognized selector sent to instance 0x1028b1

If you want, here is my .m:

Code:
#import "VideoView.h"
#import <MediaPlayer/MediaPlayer.h>

@implementation VideoView
@synthesize player;

- (void)playVideoWithURL:(NSURL *)url showControls:(BOOL)showControls {
    if (!player) {
        player = [[MPMoviePlayerController alloc] initWithContentURL:url];

        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(didFinishPlaying:) name:MPMoviePlayerPlaybackDidFinishNotification object:player];

        if (!showControls) {
                player.scalingMode = MPMovieScalingModeAspectFill;
                player.movieControlMode = MPMovieControlModeHidden;
        }

        [player play];
    }
}

- (IBAction)playVideoWithControls {
    NSString *path = [[NSBundle mainBundle] pathForResource:@"test" ofType:@"mov"];
    NSURL *url = [NSURL fileURLWithPath:path];
    [self playVideoWithURL:url showControls:YES];
}


- (void)didFinishPlaying:(NSNotification *)notification {
    if (player == [notification object]) {      
        [[NSNotificationCenter defaultCenter] removeObserver:self name:MPMoviePlayerPlaybackDidFinishNotification object:player];
        [player release];
        player = nil;
    }
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning]; // Releases the view if it doesn't have a superview
    // Release anything that's not essential, such as cached data
}


- (void)dealloc {
    [super dealloc];
}


@end


And my .h:
Code:
#import <UIKit/UIKit.h>
#import <MediaPlayer/MediaPlayer.h>


@interface VideoView : UIViewController {
    MPMoviePlayerController *player;

}
@property (nonatomic, retain) MPMoviePlayerController *player;
- (IBAction)playVideoWithControls;


@end

Thanks. I just cant get what this error is...
 
What's the code look like that actually calls playVideoWithControls? Either you're using it improperly, or there's some leak going on is my guess.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.