Commit 701e7fa479629386035f13087fc3afaadf14450e
1 parent
b3e3deb0
no message
Showing
4 changed files
with
171 additions
and
2 deletions
Example/CNLivePlayer.xcodeproj/project.pbxproj
| ... | ... | @@ -7,6 +7,7 @@ |
| 7 | 7 | objects = { |
| 8 | 8 | |
| 9 | 9 | /* Begin PBXBuildFile section */ |
| 10 | + 081E9D3F236C112D0031F1EA /* CNLiveStreamerController.m in Sources */ = {isa = PBXBuildFile; fileRef = 081E9D3D236C112D0031F1EA /* CNLiveStreamerController.m */; }; | |
| 10 | 11 | 086413BC22EAE229008713D3 /* VideoToolbox.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 086413BB22EAE229008713D3 /* VideoToolbox.framework */; }; |
| 11 | 12 | 086413BE22EAE23E008713D3 /* libbz2.tbd in Frameworks */ = {isa = PBXBuildFile; fileRef = 086413BD22EAE23E008713D3 /* libbz2.tbd */; }; |
| 12 | 13 | 086413C022EAE24F008713D3 /* libz.tbd in Frameworks */ = {isa = PBXBuildFile; fileRef = 086413BF22EAE24F008713D3 /* libz.tbd */; }; |
| ... | ... | @@ -44,6 +45,8 @@ |
| 44 | 45 | /* End PBXContainerItemProxy section */ |
| 45 | 46 | |
| 46 | 47 | /* Begin PBXFileReference section */ |
| 48 | + 081E9D3D236C112D0031F1EA /* CNLiveStreamerController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CNLiveStreamerController.m; sourceTree = "<group>"; }; | |
| 49 | + 081E9D3E236C112D0031F1EA /* CNLiveStreamerController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CNLiveStreamerController.h; sourceTree = "<group>"; }; | |
| 47 | 50 | 086413BB22EAE229008713D3 /* VideoToolbox.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = VideoToolbox.framework; path = System/Library/Frameworks/VideoToolbox.framework; sourceTree = SDKROOT; }; |
| 48 | 51 | 086413BD22EAE23E008713D3 /* libbz2.tbd */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.text-based-dylib-definition"; name = libbz2.tbd; path = usr/lib/libbz2.tbd; sourceTree = SDKROOT; }; |
| 49 | 52 | 086413BF22EAE24F008713D3 /* libz.tbd */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.text-based-dylib-definition"; name = libz.tbd; path = usr/lib/libz.tbd; sourceTree = SDKROOT; }; |
| ... | ... | @@ -127,6 +130,15 @@ |
| 127 | 130 | path = Pods; |
| 128 | 131 | sourceTree = "<group>"; |
| 129 | 132 | }; |
| 133 | + 081E9D3A236C10D20031F1EA /* Streamer */ = { | |
| 134 | + isa = PBXGroup; | |
| 135 | + children = ( | |
| 136 | + 081E9D3E236C112D0031F1EA /* CNLiveStreamerController.h */, | |
| 137 | + 081E9D3D236C112D0031F1EA /* CNLiveStreamerController.m */, | |
| 138 | + ); | |
| 139 | + path = Streamer; | |
| 140 | + sourceTree = "<group>"; | |
| 141 | + }; | |
| 130 | 142 | 08740E5F230E8C6500B5D28D /* Player */ = { |
| 131 | 143 | isa = PBXGroup; |
| 132 | 144 | children = ( |
| ... | ... | @@ -184,6 +196,7 @@ |
| 184 | 196 | 086ECFB4231A564900598D4E /* CNLiveBaseController.m */, |
| 185 | 197 | 6003F5A5195388D20070C39A /* CNLiveViewController.h */, |
| 186 | 198 | 6003F5A6195388D20070C39A /* CNLiveViewController.m */, |
| 199 | + 081E9D3A236C10D20031F1EA /* Streamer */, | |
| 187 | 200 | 08740E5F230E8C6500B5D28D /* Player */, |
| 188 | 201 | 873B8AEA1B1F5CCA007FD442 /* Main.storyboard */, |
| 189 | 202 | 71719F9D1E33DC2100824A3D /* LaunchScreen.storyboard */, |
| ... | ... | @@ -430,6 +443,7 @@ |
| 430 | 443 | buildActionMask = 2147483647; |
| 431 | 444 | files = ( |
| 432 | 445 | 6003F59E195388D20070C39A /* CNLiveAppDelegate.m in Sources */, |
| 446 | + 081E9D3F236C112D0031F1EA /* CNLiveStreamerController.m in Sources */, | |
| 433 | 447 | 086ECFB5231A564900598D4E /* CNLiveBaseController.m in Sources */, |
| 434 | 448 | 6003F5A7195388D20070C39A /* CNLiveViewController.m in Sources */, |
| 435 | 449 | 08740E62230E8C6500B5D28D /* CNLivePlayerController.m in Sources */, | ... | ... |
Example/CNLivePlayer/CNLiveViewController.m
| ... | ... | @@ -8,7 +8,7 @@ |
| 8 | 8 | |
| 9 | 9 | #import "CNLiveViewController.h" |
| 10 | 10 | #import "CNLivePlayerController.h" |
| 11 | - | |
| 11 | +#import "CNLiveStreamerController.h" | |
| 12 | 12 | |
| 13 | 13 | @interface CNLiveViewController () |
| 14 | 14 | |
| ... | ... | @@ -52,7 +52,8 @@ |
| 52 | 52 | } |
| 53 | 53 | |
| 54 | 54 | - (void)btnDidClicked2{ |
| 55 | - | |
| 55 | + [self presentViewController:[CNLiveStreamerController new] animated:YES completion:nil]; | |
| 56 | + | |
| 56 | 57 | } |
| 57 | 58 | |
| 58 | 59 | ... | ... |
Example/CNLivePlayer/Streamer/CNLiveStreamerController.h
0 → 100644
| 1 | +// | |
| 2 | +// CNLiveStreamerController.h | |
| 3 | +// CNLivePlayer_Example | |
| 4 | +// | |
| 5 | +// Created by CNLive-zxw on 2019/8/17. | |
| 6 | +// Copyright © 2019 153993236@qq.com. All rights reserved. | |
| 7 | +// | |
| 8 | + | |
| 9 | +#import "CNLiveBaseController.h" | |
| 10 | + | |
| 11 | +NS_ASSUME_NONNULL_BEGIN | |
| 12 | + | |
| 13 | +@interface CNLiveStreamerController : CNLiveBaseController | |
| 14 | + | |
| 15 | +@end | |
| 16 | + | |
| 17 | +NS_ASSUME_NONNULL_END | ... | ... |
Example/CNLivePlayer/Streamer/CNLiveStreamerController.m
0 → 100644
| 1 | +// | |
| 2 | +// CNLiveStreamerController.m | |
| 3 | +// CNLivePlayer_Example | |
| 4 | +// | |
| 5 | +// Created by CNLive-zCNLive on 2019/8/17. | |
| 6 | +// Copyright © 2019 153993236@qq.com. All rights reserved. | |
| 7 | +// | |
| 8 | + | |
| 9 | +#import "CNLiveStreamerController.h" | |
| 10 | +#import "CNLivePlayer.h" | |
| 11 | + | |
| 12 | +@interface CNLiveStreamerController ()<CNLivePlayerDelegate> | |
| 13 | +@property (nonatomic, strong) CNLivePlayer *player; | |
| 14 | +@property (nonatomic, strong) UILabel *state; | |
| 15 | + | |
| 16 | +@end | |
| 17 | + | |
| 18 | +@implementation CNLiveStreamerController | |
| 19 | + | |
| 20 | +- (void)viewDidLoad { | |
| 21 | + [super viewDidLoad]; | |
| 22 | + self.view.backgroundColor = [UIColor whiteColor]; | |
| 23 | + | |
| 24 | + // 82_c8ff347048414b7295cef882f8361073 杨丞琳 | |
| 25 | + // 223_9855888ddc68402ca738bf302e535805 汤唯 | |
| 26 | + // 1066_716fabeaafb64236b60ecf74167c5c96 音频 | |
| 27 | + | |
| 28 | +// http://tjzghuajiao.vods2.cnlive.com/1066/vod/2019/0517/1066_716fabeaafb642K36b60ecf74167c5c96/ff8080816a6816ca016ac3bee98b5fa7_128.mp4 | |
| 29 | +// self.player = [[CNLivePlayer alloc]initWithUrl:@"http://tjzghuajiao.vods2.cnlive.com/1066/vod/2019/0517/1066_716fabeaafb64236b60ecf74167c5c96/ff8080816a6816ca016ac3bee98b5fa7_128.mp4"]; | |
| 30 | + | |
| 31 | + self.player = [[CNLivePlayer alloc]initVodPlayWithVideoId:@"223_9855888ddc68402ca738bf302e535805"]; | |
| 32 | + | |
| 33 | +// self.player = [[CNLivePlayer alloc]initVodPlayWithVideoId:@"223_9855888ddc68402ca738bf302e535805" success:^{ | |
| 34 | +// | |
| 35 | +// } failure:^(NSError * _Nonnull error) { | |
| 36 | +// | |
| 37 | +// }]; | |
| 38 | + _player.frame = CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, [UIScreen mainScreen].bounds.size.width*9/16.0); | |
| 39 | + _player.backgroundPlayEnable = YES; | |
| 40 | + _player.delegate = self; | |
| 41 | + [self.view addSubview:self.player.view]; | |
| 42 | + [_player play]; | |
| 43 | + | |
| 44 | + | |
| 45 | + UIButton *btn1 = [UIButton buttonWithType:UIButtonTypeCustom]; | |
| 46 | + btn1.frame = CGRectMake(0, 0, 100, 50); | |
| 47 | + btn1.center = CGPointMake(self.view.center.x, self.view.center.y-100); | |
| 48 | + btn1.backgroundColor = [UIColor redColor]; | |
| 49 | + [btn1 setTitle:@"下一个" forState:UIControlStateNormal]; | |
| 50 | + [btn1 setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal]; | |
| 51 | + [btn1 addTarget:self action:@selector(btnDidClicked1) forControlEvents:UIControlEventTouchUpInside]; | |
| 52 | + [self.view addSubview:btn1]; | |
| 53 | + | |
| 54 | + UIButton *btn2 = [UIButton buttonWithType:UIButtonTypeCustom]; | |
| 55 | + btn2.frame = CGRectMake(0, 0, 100, 50); | |
| 56 | + btn2.center = CGPointMake(self.view.center.x-100, self.view.center.y+100); | |
| 57 | + btn2.backgroundColor = [UIColor redColor]; | |
| 58 | + [btn2 setTitle:@"切换码率1" forState:UIControlStateNormal]; | |
| 59 | + [btn2 setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal]; | |
| 60 | + [btn2 addTarget:self action:@selector(btnDidClicked2) forControlEvents:UIControlEventTouchUpInside]; | |
| 61 | + [self.view addSubview:btn2]; | |
| 62 | + | |
| 63 | + UIButton *btn4 = [UIButton buttonWithType:UIButtonTypeCustom]; | |
| 64 | + btn4.frame = CGRectMake(0, 0, 100, 50); | |
| 65 | + btn4.center = CGPointMake(self.view.center.x+100, self.view.center.y+100); | |
| 66 | + btn4.backgroundColor = [UIColor redColor]; | |
| 67 | + [btn4 setTitle:@"切换码率2" forState:UIControlStateNormal]; | |
| 68 | + [btn4 setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal]; | |
| 69 | + [btn4 addTarget:self action:@selector(btnDidClicked4) forControlEvents:UIControlEventTouchUpInside]; | |
| 70 | + [self.view addSubview:btn4]; | |
| 71 | + | |
| 72 | + UIButton *btn3 = [UIButton buttonWithType:UIButtonTypeCustom]; | |
| 73 | + btn3.frame = CGRectMake(0, 0, 100, 50); | |
| 74 | + btn3.center = CGPointMake(self.view.center.x, self.view.center.y+200); | |
| 75 | + btn3.backgroundColor = [UIColor redColor]; | |
| 76 | + [btn3 setTitle:@"返回" forState:UIControlStateNormal]; | |
| 77 | + [btn3 setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal]; | |
| 78 | + [btn3 addTarget:self action:@selector(btnDidClicked3) forControlEvents:UIControlEventTouchUpInside]; | |
| 79 | + [self.view addSubview:btn3]; | |
| 80 | + | |
| 81 | + self.state = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, 200, 20)]; | |
| 82 | + self.state.backgroundColor = [UIColor redColor]; | |
| 83 | + self.state.center = CGPointMake(self.view.center.x, self.view.center.y+300); | |
| 84 | + [self.view addSubview:self.state]; | |
| 85 | + | |
| 86 | +} | |
| 87 | + | |
| 88 | +- (void)dealloc{ | |
| 89 | + | |
| 90 | +} | |
| 91 | +- (void)btnDidClicked1{ | |
| 92 | + [_player switchVideo:@"82_c8ff347048414b7295cef882f8361073" type:CNLivePlayerDataTypeVod]; | |
| 93 | + [_player play]; | |
| 94 | + | |
| 95 | +} | |
| 96 | +- (void)btnDidClicked2{ | |
| 97 | + self.state.text = @"切换中"; | |
| 98 | + [_player switchRate:kCNLiveClarity_1080P]; | |
| 99 | + | |
| 100 | +} | |
| 101 | + | |
| 102 | +- (void)btnDidClicked4{ | |
| 103 | + self.state.text = @"切换中"; | |
| 104 | + [_player switchRate:kCNLiveClarity_360P]; | |
| 105 | +} | |
| 106 | +- (void)btnDidClicked3{ | |
| 107 | + [self dismissViewControllerAnimated:YES completion:nil]; | |
| 108 | + | |
| 109 | +} | |
| 110 | +/* | |
| 111 | +#pragma mark - Navigation | |
| 112 | + | |
| 113 | +// In a storyboard-based application, you will often want to do a little preparation before navigation | |
| 114 | +- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { | |
| 115 | + // Get the new view controller using [segue destinationViewController]. | |
| 116 | + // Pass the selected object to the new view controller. | |
| 117 | +} | |
| 118 | +*/ | |
| 119 | +- (void)player:(nonnull CNLivePlayer *)player statusDidChange:(CNLivePlayerStatus)state{ | |
| 120 | + if(state == CNLivePlayerStatusOpen){ | |
| 121 | + | |
| 122 | + } | |
| 123 | +} | |
| 124 | + | |
| 125 | +- (void)player:(nonnull CNLivePlayer *)player seekToCompleted:(BOOL)isCompleted{ | |
| 126 | + | |
| 127 | +} | |
| 128 | +- (void)player:(nonnull CNLivePlayer *)player switchRateCompleted:(BOOL)isCompleted{ | |
| 129 | + self.state.text = isCompleted?@"切换完成":@"切换失败"; | |
| 130 | +} | |
| 131 | +- (void)player:(nonnull CNLivePlayer *)player stoppedWithError:(nullable NSError *)error{ | |
| 132 | + | |
| 133 | +} | |
| 134 | + | |
| 135 | + | |
| 136 | +@end | |
| 137 | + | ... | ... |