iOS在线播放--影音播放的两个方式
2015-06-25 11:02
507 查看
#import "ViewController.h"
#import <MediaPlayer/MediaPlayer.h>
#import <AVFoundation/AVFoundation.h>
@interface
ViewController ()
@property (strong,nonatomic)
AVPlayer *avPlayer;
@property (strong,nonatomic)
MPMoviePlayerController *mpPlayer;
@end
@implementation ViewController
- (void)viewDidLoad {
[super
viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
}
- (void)didReceiveMemoryWarning {
[super
didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
//192.168.0.125
NSURL *url=[NSURL
URLWithString:@"http://192.168.0.125:8080/WYServer/resources/htmls/Go.mp3"];
NSURL *urlMoive=[NSURL
URLWithString:@"http://192.168.0.125:8080/WYServer/resources/videos/minion_01.mp4"];
// self.avPlayer = [[AVPlayer alloc] initWithURL:url];
// [self.avPlayer play];
//------方式1------
// self.mpPlayer=[[MPMoviePlayerController alloc] initWithContentURL:urlMoive];
// [self.view addSubview:self.mpPlayer.view];
// [self.mpPlayer setFullscreen:YES];
//
// [self.mpPlayer play];
//------方式2------
[self
presentMoviePlayerViewControllerAnimated:[[MPMoviePlayerViewController
alloc] initWithContentURL:urlMoive]];
}
@end
#import <MediaPlayer/MediaPlayer.h>
#import <AVFoundation/AVFoundation.h>
@interface
ViewController ()
@property (strong,nonatomic)
AVPlayer *avPlayer;
@property (strong,nonatomic)
MPMoviePlayerController *mpPlayer;
@end
@implementation ViewController
- (void)viewDidLoad {
[super
viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
}
- (void)didReceiveMemoryWarning {
[super
didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
//192.168.0.125
NSURL *url=[NSURL
URLWithString:@"http://192.168.0.125:8080/WYServer/resources/htmls/Go.mp3"];
NSURL *urlMoive=[NSURL
URLWithString:@"http://192.168.0.125:8080/WYServer/resources/videos/minion_01.mp4"];
// self.avPlayer = [[AVPlayer alloc] initWithURL:url];
// [self.avPlayer play];
//------方式1------
// self.mpPlayer=[[MPMoviePlayerController alloc] initWithContentURL:urlMoive];
// [self.view addSubview:self.mpPlayer.view];
// [self.mpPlayer setFullscreen:YES];
//
// [self.mpPlayer play];
//------方式2------
[self
presentMoviePlayerViewControllerAnimated:[[MPMoviePlayerViewController
alloc] initWithContentURL:urlMoive]];
}
@end
相关文章推荐
- iOS_开发中遇到的那些问题_1
- DTCoreText 要点记录
- [Jenkins] Jenkins配置IOS持续环境,构建出现IDEArchivePathOverride问题!
- iOS#define和static const
- iOS 常见小问题
- iOS学习笔记—视2图上移与键盘弹回
- iOS 开发数据存储之magic record
- iOSMVVM(Model-View(View/ViewController) -ViewModel ) 设计模式
- ios通知中心
- ios常见加密解密方法
- iOS 8 AutoLayout与Size Class
- iOS md5 32位加密(区分大小写)
- textfield限制字数(兼容中文,复制,删除)iOS
- iOS7新特性总结
- iOS证书共享
- iOS支付宝报错 rsa_private read error : private key is NULL
- Zxing使用及常见错误(iOS)
- iOS真机测试
- 简述 IOS中的LazyLoad思想
- iOS archive(归档)的总结