media player - IOS MPMoviePlayerViewController Loading endlessly -
i'm working on ios app (with storyoard). have viewcontroller:
//movieviewcontroller.h #import <uikit/uikit.h> #import <mediaplayer/mediaplayer.h> @interface movieviewcontroller : uiviewcontroller { mpmovieplayerviewcontroller *movieplayer; } @property (strong, nonatomic) mpmovieplayerviewcontroller *movieplayer; -(void) playmovie; @end //movieviewcontroller.m - (void)viewdidload { [super viewdidload]; // additional setup after loading view. [self playmovie]; } -(void)playmovie { nsstring *videopath = [[nsbundle mainbundle] pathforresource:@"movie" oftype:@"mov"]; movieplayer = [[mpmovieplayerviewcontroller alloc] initwithcontenturl:[nsurl fileurlwithpath:videopath]]; [self presentmovieplayerviewcontrolleranimated:movieplayer]; }
when run see viewcontroller "loading..." takes forever.
you should call -preparetoplay
and/or -play
. per mpmovieplayercontroller
's documentation:
starting in ios 5.0, in order facilitate finer-grained playback control, new movie player not automatically prepared play.
Comments
Post a Comment