播放在线的网络视频
UIWebView *myWeb = [[UIWebView alloc] initWithFrame:self.view.bounds];
NSURL *url = [NSURLURLWithString:@"
http://devimages.apple.com/iphone/samples/bipbop/gear1/prog_index.m3u8"];
http://devimages.apple.com/iphone/samples/bipbop/gear1/prog_index.m3u8//这里也可以是 mp4
NSURLRequest *request = [NSURLRequest requestWithURL:url];
[myWeb setDelegate:self];
[myWeb loadRequest:request];
//AVPlayerLayer 播放在线视频
NSURL *sourceMovieURL = [NSURL URLWithString:@"http://clips.vorwaerts-gmbh.de/big_buck_bunny.mp4"];
AVAsset *movieAsset = [AVURLAsset URLAssetWithURL:sourceMovieURLoptions:nil];
AVPlayerItem *playerItem = [AVPlayerItem playerItemWithAsset:movieAsset];
AVPlayer *player = [AVPlayer playerWithPlayerItem:playerItem];
AVPlayerLayer *playerLayer = [AVPlayerLayer playerLayerWithPlayer:player];
playerLayer.frame = self.view.layer.bounds;
playerLayer.videoGravity = AVLayerVideoGravityResizeAspect;
[self.view.layer addSublayer:playerLayer];
转载请标明出处,黄志勇的个人博客!
//MPMoviePlayerController 播放在线视频
NSURL *videoURL = [NSURLURLWithString:@"https://s3.amazonaws.com/adplayer/colgate.mp4"];
MPMoviePlayerViewcontroller *moviePlayerController = [[MPMoviePlayerViewcontroller alloc] initWithContentURL:videoURL];
moviePlayerController.moviePlayer.movieSourceType = MPMovieSourceTypeFile;
moviePlayerController.moviePlayer.shouldAutoplay = YES;
//moviePlayerController.moviePlayer.controlStyle = MPMovieControlStyleNone;
[moviePlayerController.moviePlayer prepareToPlay];
[moviePlayerController.moviePlayer play];
[[NSnotificationCenter defaultCenter]
addObserver: self
selector: @selector(myMovieFinishedCallback:)
name: MPMoviePlayerPlaybackDidFinishnotification
object: moviePlayerController];
[self presentMoviePlayerViewcontrollerAnimated:moviePlayerController];
版权声明:
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。
如若内容造成侵权、违法违规、事实不符,请将相关资料发送至xkadmin@xkablog.com进行投诉反馈,一经查实,立即处理!
转载请注明出处,原文链接:https://www.xkablog.com/iosbc/10182.html