ios - Get Local Document Video File but Black screen come again -
nsarray *paths = nssearchpathfordirectoriesindomains(nsdocumentdirectory, nsuserdomainmask, yes); nsstring *documentsdirectory = [paths objectatindex:0]; nsstring *pathvideo = [documentsdirectory stringbyappendingpathcomponent:@"myvideo.mp4"]; nsurl *movieurl = [nsurl fileurlwithpath:pathvideo]; self.movieplayer = [[mpmovieplayercontroller alloc] init]; [self.movieplayer setshouldautoplay:yes]; [self.movieplayer setcontenturl:movieurl.absoluteurl]; [self.movieplayer setmoviesourcetype:mpmoviesourcetypefile]; [self.movieplayer setcontrolstyle:mpmoviecontrolmodedefault]; [self.movieplayer setfullscreen:no]; [self.movieplayer setscalingmode:mpmoviescalingmodenone]; self.movieplayer.view.frame = cgrectmake(40, 40, 240, 350); [self.view addsubview:self.movieplayer.view]; [self.movieplayer preparetoplay]; [self.movieplayer play];
let's try:
nsarray *paths = nssearchpathfordirectoriesindomains(nsdocumentdirectory, nsuserdomainmask, yes); nsstring *documentsdirectory = [paths objectatindex:0]; nsstring *pathvideo = [documentsdirectory stringbyappendingpathcomponent:@"myvideo.mp4"]; bool isexisted = [[nsfilemanager defaultmanager] fileexistsatpath:pathvideo]; // sure isexisted yes == file existed @ path
i try , works, can play videos.
Comments
Post a Comment