gmemario
gmemario

Reputation: 1210

I can't create an object of type MPMoviePlayerController - Unknown type

I'm trying to create a component to play videos using MPMoviePlayerController. The problem is that it says that its an unknown type. Why is that? I've found tons of tutorials using this.

Here's my code:

@interface HIMoviePlayer : UIViewController
{
    MPMoviePlayerController *test;
}

-(void) playVideoWithURL: (NSString *) url;
@end

Upvotes: 0

Views: 1198

Answers (2)

Nat
Nat

Reputation: 12948

It's totally strange but if you add MPMoviePlayerController to UIView instead of UIViewController it firstly shows error, then if you change superclass to UIViewController, build and change it back to UIView, everything works fine (no errors and MPMoviePlayerController is showing it's content correctly). At least it happened to me, wouldn't mind if someone explains why i occured such behaviour.

Upvotes: 0

DanKiiing
DanKiiing

Reputation: 102

Make sure you import the mediaplayer framework into the header file,

i.e

 #import <UIKit/UIkit.h>
 #import <MediaPlayer/MediaPlayer.h>
 @interface HIMoviePlayer : UIViewController
 {
 MPMoviePlayerController *test;
 }

 -(void) playVideoWithURL: (NSString *) url;
 @end

I encountered this problem also, but this should fix it.

Upvotes: 4

Related Questions