ViewController.m 3.51 KB
//
//  ViewController.m
//  CNLivePlayerSDKTest
//
//  Created by 雷浩杰 on 16/8/10.
//  Copyright © 2016年 雷浩杰. All rights reserved.
//

#import "ViewController.h"
#import "PlayerViewController.h"
#import "BarrageViewController.h"
#import "StreamerViewController.h"

@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.title = @"视讯云 推流和播放SDK Demo";
    
    UIButton *playerBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    playerBtn.frame = CGRectMake((CGRectGetWidth(self.view.frame)-150)/2, 100, 150, 50);
    [playerBtn setTitle:@"播放" forState:UIControlStateNormal];
    [playerBtn setTitleColor:[UIColor colorWithRed:23/255.0 green:110/255.0 blue:254/255.0 alpha:1] forState:UIControlStateNormal];
    [playerBtn addTarget:self action:@selector(playerBtnAction) forControlEvents:UIControlEventTouchUpInside];
    playerBtn.layer.cornerRadius = 10;
    playerBtn.layer.masksToBounds = YES;
    playerBtn.layer.borderColor = [UIColor blackColor].CGColor;
    playerBtn.layer.borderWidth = 1;
    [self.view addSubview:playerBtn];
    
    UIButton *streamerBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    streamerBtn.frame = CGRectMake((CGRectGetWidth(self.view.frame)-150)/2, 200, 150, 50);
    [streamerBtn setTitle:@"推流" forState:UIControlStateNormal];
    [streamerBtn setTitleColor:[UIColor colorWithRed:23/255.0 green:110/255.0 blue:254/255.0 alpha:1] forState:UIControlStateNormal];
    [streamerBtn addTarget:self action:@selector(streamerBtnAction) forControlEvents:UIControlEventTouchUpInside];
    streamerBtn.layer.cornerRadius = 10;
    streamerBtn.layer.masksToBounds = YES;
    streamerBtn.layer.borderColor = [UIColor blackColor].CGColor;
    streamerBtn.layer.borderWidth = 1;
    [self.view addSubview:streamerBtn];
    
    UIButton *barrageBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    barrageBtn.frame = CGRectMake((CGRectGetWidth(self.view.frame)-150)/2, 300, 150, 50);
    [barrageBtn setTitle:@"弹幕" forState:UIControlStateNormal];
    [barrageBtn setTitleColor:[UIColor colorWithRed:23/255.0 green:110/255.0 blue:254/255.0 alpha:1] forState:UIControlStateNormal];
    [barrageBtn addTarget:self action:@selector(barrageBtnAction) forControlEvents:UIControlEventTouchUpInside];
    barrageBtn.layer.cornerRadius = 10;
    barrageBtn.layer.masksToBounds = YES;
    barrageBtn.layer.borderColor = [UIColor blackColor].CGColor;
    barrageBtn.layer.borderWidth = 1;
    [self.view addSubview:barrageBtn];
    
    UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0, CGRectGetHeight([UIScreen mainScreen].bounds)-60, CGRectGetWidth(self.view.frame), 30)];
    label.text = @"北京中投视讯文化传媒股份有限公司";
    [self.view addSubview:label];
    label.font = [UIFont systemFontOfSize:12];
    label.textAlignment = NSTextAlignmentCenter;
}

- (void)playerBtnAction
{
    PlayerViewController *player = [[PlayerViewController alloc] init];
    [self presentViewController:player animated:YES completion:NULL];
}

- (void)barrageBtnAction
{
    BarrageViewController *player = [[BarrageViewController alloc] init];
    [self presentViewController:player animated:YES completion:NULL];
}

- (void)streamerBtnAction
{
    StreamerViewController *streamer = [[StreamerViewController alloc] init];
    [self presentViewController:streamer animated:YES completion:NULL];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end