iOS在线播放--影音播放的两个方式

来源:互联网 发布:java重载构造函数格式 编辑:程序博客网 时间:2024/04/29 10:39

#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 {

    [superviewDidLoad];

    // Do any additional setup after loading the view, typically from a nib.

}


- (void)didReceiveMemoryWarning {

    [superdidReceiveMemoryWarning];

    // Dispose of any resources that can be recreated.

}

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event

{

    //192.168.0.125

    NSURL *url=[NSURLURLWithString:@"http://192.168.0.125:8080/WYServer/resources/htmls/Go.mp3"];

    NSURL *urlMoive=[NSURLURLWithString:@"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------

    [selfpresentMoviePlayerViewControllerAnimated:[[MPMoviePlayerViewControlleralloc] initWithContentURL:urlMoive]];

    

}

@end


0 0
原创粉丝点击