iphone - MPMoviePlayerController iO7 issue -
i trying play video stored in application's documents directory through mpmovieplayercontroller. using following method play video:
nsarray *directorypath = nssearchpathfordirectoriesindomains(nsdocumentdirectory, nsuserdomainmask, yes); nsstring *docsdir = [directorypath objectatindex:0]; int videonumber = (int)[[nsuserdefaults standarduserdefaults] integerforkey:@"videosaved"]; nsstring* videoname = [nsstring stringwithformat:@"video-%d.mov",videonumber]; nsstring *exportpath = [docsdir stringbyappendingpathcomponent:videoname]; nsurl *exporturl = [nsurl fileurlwithpath:exportpath isdirectory:no]; movieplayer = [[mpmovieplayercontroller alloc] initwithcontenturl:exporturl]; movieplayer.fullscreen = yes; movieplayer.view.frame = self.view.bounds; [self.view addsubview:movieplayer.view]; [movieplayer preparetoplay]; [movieplayer play]; [[nsnotificationcenter defaultcenter] addobserver:self selector:@selector(moviedidexitfullscreen:) name:mpmovieplayerplaybackdidfinishnotification object:nil];
it works fine on ios versions except ios7. in ios7 when try play video ives me error:
_itemfailedtoplaytoend: { kind = 1; new = 2; old = 0;}
try change code this:
int videonumber = (int)[[nsuserdefaults standarduserdefaults] integerforkey:@"videosaved"]; movieplayer= [[mpmovieplayercontroller alloc] initwithcontenturl: [nsurl fileurlwithpath: [[nsbundle mainbundle] pathforresource: [nsstring stringwithformat:@"video-%d",videonumber] oftype:@"mov"]]]; movieplayer.fullscreen = yes; movieplayer.moviesourcetype = mpmoviesourcetypefile; movieplayer.view.frame = self.view.bounds; [self.view addsubview:movieplayer.view]; [movieplayer preparetoplay]; [movieplayer play]; [[nsnotificationcenter defaultcenter] addobserver:self selector:@selector(moviedidexitfullscreen:) name:mpmovieplayerplaybackdidfinishnotification object:nil];
Comments
Post a Comment