iOS-流媒体 AutoStreamerPlayer

AutoStreamerPlayer:

//定义流媒体播放器对象
    AudioStreamer *_streamer;
_streamer = [[AudioStreamer alloc] initWithURL:[NSURL URLWithString:@"http://yinyueshiting.baidu.com/data2/music/121379113/121367437219600128.mp3?xcode=bea5ad048be8ac39ee0dd05f0d2997c03ef67e2e5568d8d2"]];
    _streamer.bitRate = 10;   
    [_streamer start];


MediaStreamerPlayer:

- (void)viewDidLoad
{
    [super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
    
    //演示如何播放在线视频文件
    //在线视频播放分为2种形式:
    
    //<1>点播
        //播放视频, 用户任意拖动观看的时间
        //在线网络视频(优酷,土豆,ku6)
    [self testMediaStreamerPlayer];


    //<2>m3u8格式点播
    [self testM3u8Player];
    
    //<3>m3u8格式直播
        //电视就是直播形式, 任意时刻只能观看当前时间的电视
    // http://219.232.160.141:5080/hls/c64024e7cd451ac19613345704f985fa.m3u8
    [self testM3u8DirectPlayer];
    
}


-(void)testM3u8DirectPlayer
{
    UIButton *button = [UIButton systemButtonWithFrame:CGRectMake(100, 200, 100, 30) title:@"m3u8直播" action:^(UIButton *button) {
        
        MPMoviePlayerViewController *mpvc = [[MPMoviePlayerViewController alloc] initWithContentURL:[NSURL URLWithString:@"http://219.232.160.141:5080/hls/c64024e7cd451ac19613345704f985fa.m3u8"]];
        
        [self presentViewController:mpvc animated:YES completion:nil];
        
    }];
    [self.view addSubview:button];


    
}


-(void)testM3u8Player
{


    UIButton *button = [UIButton systemButtonWithFrame:CGRectMake(100, 150, 100, 30) title:@"m3u8点播" action:^(UIButton *button) {
        
        MPMoviePlayerViewController *mpvc = [[MPMoviePlayerViewController alloc] initWithContentURL:[NSURL URLWithString:@"http://pl.youku.com/playlist/m3u8?ts=1418780031&keyframe=0&vid=XODQ2NjU5Nzky&type=mp4&ep=eyaVEk6FVMcE4SXfjT8bMyzlciYHXJZ1gn6H%2F4gHBcVuE6HQkD%2FQxg%3D%3D&sid=941878294460512d076a8&token=9111&ctype=12&ev=1&oip=3663591661"]];
        
        [self presentViewController:mpvc animated:YES completion:nil];
        
        
    }];
    [self.view addSubview:button];
}


-(void)testMediaStreamerPlayer
{
    UIButton *button = [UIButton systemButtonWithFrame:CGRectMake(100, 100, 100, 30) title:@"点播" action:^(UIButton *button) {
        
        // http://k.youku.com/player/getFlvPath/sid/941878294460512d076a8_01/st/mp4/fileid/0300200100548A9028146A11EC8DDC97DFAAE0-0870-323E-1C23-67FF658E7AE3?K=6e64e3af1073bf12282a1852&hd=0&ymovie=1&myp=0&ts=1386&ypp=2&ctype=12&ev=1&token=9111&oip=3663591661&ep=eyaVEk6FVMcE4SXfjT8bMyzlciYHXP4J9h%2BHgdJjALshTODOkD7Tz5y0SI5DF4xqelZyY%2BL236aWGzUUYfBLrmgQ3EyrTPrhjfLg5atUsuYGYxFDdbyit1SXQjHw
        
        MPMoviePlayerViewController *mpvc = [[MPMoviePlayerViewController alloc] initWithContentURL:[NSURL URLWithString:@"http://k.youku.com/player/getFlvPath/sid/941878294460512d076a8_01/st/mp4/fileid/0300200100548A9028146A11EC8DDC97DFAAE0-0870-323E-1C23-67FF658E7AE3?K=6e64e3af1073bf12282a1852&hd=0&ymovie=1&myp=0&ts=1386&ypp=2&ctype=12&ev=1&token=9111&oip=3663591661&ep=eyaVEk6FVMcE4SXfjT8bMyzlciYHXP4J9h%2BHgdJjALshTODOkD7Tz5y0SI5DF4xqelZyY%2BL236aWGzUUYfBLrmgQ3EyrTPrhjfLg5atUsuYGYxFDdbyit1SXQjHw"]];
        
        [self presentViewController:mpvc animated:YES completion:nil];
        
        
    }];
    [self.view addSubview:button];
                    
}

你可能感兴趣的:(iOS-流媒体 AutoStreamerPlayer)