objective c - Play Video like youtube in iOS 8 -
i want play video youtube in ios using objective c , video file come url. can guide me how or there way video buffering in efficient way.
buffering tube can accomplished native objective c "mpmoviecontroller". can check out if works you.
mpmovieplayerviewcontroller* mpmovieplayercontroller = [[mpmovieplayerviewcontroller alloc] initwithcontenturl:url]; [[nsnotificationcenter defaultcenter] addobserver:self selector:@selector(movieplaybackcomplete:) name:mpmovieplayerplaybackstatedidchangenotification object:nil]; [[nsnotificationcenter defaultcenter] addobserver:self selector:@selector(movieplaybackcomplete:) name:mpmovieplayerplaybackdidfinishnotification object:nil]; [[nsnotificationcenter defaultcenter] addobserver:self selector:@selector(movieplaybackcomplete:) name:mpmovieplayerwillexitfullscreennotification object:nil]; movieplayercontroller.movieplayer.fullscreen=yes; movieplayercontroller.movieplayer.shouldautoplay=yes; [self presentmovieplayerviewcontrolleranimated:movieplayercontroller];
declare mpmovieplayercontroller global variable.then handle notifications defining selector methods per requirements.
- (void)movieplaybackcomplete:(nsnotification *)notification { if([notification.name isequal:mpmovieplayerplaybackdidfinishnotification]) { nserror *error = [[notification userinfo] objectforkey:@"error"]; if (error) { nslog(@"did finish error: %@", error); } [[nsnotificationcenter defaultcenter] removeobserver:self name:mpmovieplayerplaybackdidfinishnotification object:nil]; [movieplayercontroller.movieplayer stop]; movieplayercontroller = nil; [self dismissmovieplayerviewcontrolleranimated]; } else if([notification.name isequal:mpmovieplayerwillexitfullscreennotification]) { [[nsnotificationcenter defaultcenter] removeobserver:self name:mpmovieplayerwillexitfullscreennotification object:nil]; [movieplayercontroller.movieplayer stop]; movieplayercontroller = nil; [self dismissmovieplayerviewcontrolleranimated]; } }
Comments
Post a Comment