#import "ViewController.h"
@import MediaPlayer;
@interface Viewcontroller ()
{
MPMoviePlayerController *_mov;
}
@property (Weak, nonatomic) Iboutlet Uiimageview *xianshi;
@end
@implementation Viewcontroller
-(Ibaction) Didclickdo: (ID) Sender {
MPMoviePlayerController *play = [[MPMoviePlayerController alloc] initwithcontenturl:@ "/users/apple/desktop/ Hdmv.mp4 "];
[Self presentmovieplayerviewcontrolleranimated:play];
The way it's been obsolete
UIImage *image = [_mov thumbnailimageattime:100 timeoption:mpmovietimeoptionnearestkeyframe];
_xianshi.image = image;
Now the
[_mov requestthumbnailimagesattimes:@[@1.0,@10.0,@30.0] timeoption:mpmovietimeoptionnearestkeyframe];//on effective virginity
}
-(void) Didthumb: (nsnotification *) notification
{
NSLog (@ "%@", notification.userinfo);//The specific time
UIImage *image = Notification.userinfo[mpmovieplayerthumbnailimagekey];
if (image) {
_xianshi.image = image;//Capture Successful display
}
}
-(void) Viewdidload {
[Super Viewdidload];
[[Nsnotificationcenter Defaultcenter] addobserver:self selector: @selector (didplaybacknotif:) Name: Mpmovieplayerplaybackstatedidchangenotification Object:nil];
[[Nsnotificationcenter Defaultcenter] addobserver:self selector: @selector (didthumb:) Name: Mpmovieplayerthumbnailimagerequestdidfinishnotification Object:nil];
Nsurl *url = [Nsurl fileurlwithpath:@ "/users/apple/desktop/hdmv.mp4"];//Path
_mov = [[MPMoviePlayerController Alloc]initwithcontenturl:url];
_mov.view.frame = CGRectMake (100, 100, 200, 100);//Playback position
_mov.controlstyle = Mpmoviecontrolstylenone;
_mov.shouldautoplay = NO;
[_mov preparetoplay];//start playing
[_mov play];
[Self.view Addsubview:_mov.view];
}
iOS video playback