ios - don't show movie in document folder in xcode -
i create 1 application show file in document folder. have 1 file .mov format want show document folder when run app , click play button don't show movie , see image :
this code : (please guide me , tell me mistake)
- (ibaction)play:(id)sender { nsstring *documentpath = [nssearchpathfordirectoriesindomains(nsdocumentationdirectory, nsuserdomainmask, yes)objectatindex:0]; nsstring *file = [documentpath stringbyappendingpathcomponent:@"xcode4-outlet.mov"]; nsurl *url = [nsurl fileurlwithpath:file]; _movieplayer = [[mpmovieplayercontroller alloc]initwithcontenturl:url]; [self.view addsubview:_movieplayer.view]; _movieplayer.fullscreen = yes; _movieplayer.shouldautoplay = yes; _movieplayer.allowsairplay = yes; [_movieplayer play]; }
also compiler me massage :
movie player[9489:c07] [mpavcontroller] autoplay: keep or full buffer: 0 movie player[9489:c07] [mpavcontroller] autoplay: skipping autoplay, not enough buffered keep up. movie player[9489:c07] [mpavcontroller] autoplay: enabling autoplay movie player[9489:c07] [mpcloudassetdownloadcontroller] prioritization requested media item id: 0 movie player[9489:c07] [mpavcontroller] autoplay: enabling autoplay
you need check whether file there or not before adding movie player can add default
-(ibaction)play:(id)sender { nsstring *documentpath = [nssearchpathfordirectoriesindomains(nsdocumentationdirectory, nsuserdomainmask, yes)objectatindex:0]; nsstring *file = [documentpath stringbyappendingpathcomponent:@"xcode4-outlet.mov"]; nsurl *url = [nsurl fileurlwithpath:file]; bool fileexists = [[nsfilemanager defaultmanager] fileexistsatpath:file]; if(fileexists) { _movieplayer = [[mpmovieplayercontroller alloc]initwithcontenturl:url]; [[nsnotificationcenter defaultcenter] addobserver:self selector:@selector(moviepreloaddidfinish:) name:mpmovieplayerloadstatedidchangenotification object:_movieplayer]; _movieplayer.shouldautoplay=no; [_movieplayer preparetoplay]; } }
add movie after movie loaded
-(void)moviepreloaddidfinish:(nsnotification*)notification { _movieplayer.controlstyle=mpmoviecontrolstyledefault; [self.view addsubview:_movieplayer.view]; [_movieplayer play]; [_movieplayer setfullscreen:yes animated:yes]; }
Comments
Post a Comment