MPMoviePlayerViewController视频播放

[objc]  view plain copy
  1. //通过网络地址获取视频  
[objc]  view plain copy
  1.   
[objc]  view plain copy
  1. NSString *path = [NSString stringWithFormat:@"http://v.youku.com/player/getM3U8/vid/XNzM0MDkxMjgw/type/flv/v.m3u8"];  
  2.     NSURL *url = [NSURL URLWithString:path];  
  3.     _mp = [[MPMoviePlayerViewController alloc] initWithContentURL:url];  
  4.   
  5. //    [_mp.moviePlayer setScalingMode: MPMovieScalingModeAspectFill];  
  6.     [_mp.moviePlayer setControlStyle:MPMovieControlStyleEmbedded];//控制台  
  7.      [_mp.view setFrame:CGRectMake(00320200)];  
  8.      [_mp.moviePlayer prepareToPlay];  
  9.     [self presentMoviePlayerViewControllerAnimated:_mp];  

[objc]  view plain copy
  1. //获取本地路径  
  2.     NSString *path = [[NSBundle mainBundle] pathForResource:@"hd" ofType:@"mp4"];  
  3.      
  4.       
  5.       
  6.     _mp = [[MPMoviePlayerViewController alloc] initWithContentURL:[NSURL fileURLWithPath:path]];  
  7.      
  8.     [_mp.moviePlayer setScalingMode: MPMovieScalingModeAspectFill];  
  9.     [_mp.moviePlayer setControlStyle:MPMovieControlStyleEmbedded];//控制台  
  10.      [_mp.view setFrame:CGRectMake(1010320200)];  
  11.      [_mp.moviePlayer prepareToPlay];  
  12.     [self presentMoviePlayerViewControllerAnimated:_mp];  
  13. //    MPMoviePlayerPlaybackDidFinishNotification 捕捉播放停止的消息  
  14.     
  15.     [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(play) name:MPMoviePlayerPlaybackDidFinishNotification  
  16.                                                object:nil];  
[objc]  view plain copy
  1. - (void)play  
  2. {  
  3.     NSLog(@"stop");  
  4.     [_mp release];  
  5. }  
转载:http://blog.csdn.net/yy_seven/article/details/36190741

你可能感兴趣的:(MPMoviePlayerViewController视频播放)