ios - video cover image selector from user dynamically -
i developing video application in required video cover image , select user,
select cover image user below image
search many times in google custom controller didn't result, if there custom controller ?? or suggestion helpful me
actully can video thumb cover image using path of video file using bellow code or can frame of video file. there apple not provide view-controller choose cover image thumb video. have create manually time @ thumbnailimageattime
or create own type of view , thumb image using bellow code. hope useful.
-(void) getallimagesfromvideo { imagesarray = [[nsmutablearray alloc] initwithcapacity:375]; times = [[nsmutablearray alloc] initwithcapacity:375]; (float64 = 0; < 15; += 0.033) // 25 fps in 15 sec of video { [times addobject:[nsvalue valuewithcmtime:cmtimemakewithseconds(i, 60)]]; } [imagegenerator generatecgimagesasynchronouslyfortimes:times completionhandler:^(cmtime requestedtime, cgimageref image, cmtime actualtime, avassetimagegeneratorresult result, nserror *error) { if (result == avassetimagegeneratorsucceeded) { [imagesarray addobject:[uiimage imagewithcgimage:image]]; cgimagerelease(image); } }]; }
above code ref get frames of video ios 6 here have frame image of video. create own view-controller
mention image in question create view-controller
above , set image in horizontal scroll-view
, select cover image else can particular image time using bellow code directionally .
-(uiimage *)getthumbnail:(nsstring*)stringpath { nsurl *videourl = [nsurl fileurlwithpath:stringpath]; mpmovieplayercontroller *player = [[mpmovieplayercontroller alloc] initwithcontenturl:videourl]; uiimage *thumbnail = [player thumbnailimageattime:1.0 timeoption:mpmovietimeoptionnearestkeyframe]; //player autoplays audio on init [player stop]; return thumbnail; }
Comments
Post a Comment