Commit 685befbf2a305d21663aa399a1772c5f639d5d4f
1 parent
bc74da45
no message
Showing
8 changed files
with
93 additions
and
51 deletions
CNLiveScioLive.xcodeproj/project.pbxproj
| @@ -1699,22 +1699,22 @@ | @@ -1699,22 +1699,22 @@ | ||
| 1699 | 085D85FA2159C72F0037D480 /* Classes */ = { | 1699 | 085D85FA2159C72F0037D480 /* Classes */ = { |
| 1700 | isa = PBXGroup; | 1700 | isa = PBXGroup; |
| 1701 | children = ( | 1701 | children = ( |
| 1702 | + 085D85FF2159C72F0037D480 /* ZXVideoPlayerController.h */, | ||
| 1703 | + 085D86072159C72F0037D480 /* ZXVideoPlayerController.m */, | ||
| 1704 | + 085D86002159C72F0037D480 /* ZXVideoPlayerControlView.h */, | ||
| 1705 | + 085D86062159C72F0037D480 /* ZXVideoPlayerControlView.m */, | ||
| 1702 | 085D86942159C8110037D480 /* JGMusicManager.h */, | 1706 | 085D86942159C8110037D480 /* JGMusicManager.h */, |
| 1703 | 085D86932159C8100037D480 /* JGMusicManager.m */, | 1707 | 085D86932159C8100037D480 /* JGMusicManager.m */, |
| 1704 | - 085D85FB2159C72F0037D480 /* ZXVideo.m */, | ||
| 1705 | - 085D85FC2159C72F0037D480 /* ZXVideoPlayerTimeIndicatorView.h */, | ||
| 1706 | 085D85FD2159C72F0037D480 /* ZXVideoPlayerVolumeView.h */, | 1708 | 085D85FD2159C72F0037D480 /* ZXVideoPlayerVolumeView.h */, |
| 1709 | + 085D86042159C72F0037D480 /* ZXVideo.h */, | ||
| 1710 | + 085D85FB2159C72F0037D480 /* ZXVideo.m */, | ||
| 1707 | 085D85FE2159C72F0037D480 /* ZXVideoPlayerBrightnessView.h */, | 1711 | 085D85FE2159C72F0037D480 /* ZXVideoPlayerBrightnessView.h */, |
| 1708 | - 085D85FF2159C72F0037D480 /* ZXVideoPlayerController.h */, | ||
| 1709 | - 085D86002159C72F0037D480 /* ZXVideoPlayerControlView.h */, | ||
| 1710 | - 085D86012159C72F0037D480 /* ZXVideoPlayerBatteryView.m */, | 1712 | + 085D86052159C72F0037D480 /* ZXVideoPlayerBrightnessView.m */, |
| 1711 | 085D86022159C72F0037D480 /* ZXVideoPlayerVolumeView.m */, | 1713 | 085D86022159C72F0037D480 /* ZXVideoPlayerVolumeView.m */, |
| 1714 | + 085D85FC2159C72F0037D480 /* ZXVideoPlayerTimeIndicatorView.h */, | ||
| 1712 | 085D86032159C72F0037D480 /* ZXVideoPlayerTimeIndicatorView.m */, | 1715 | 085D86032159C72F0037D480 /* ZXVideoPlayerTimeIndicatorView.m */, |
| 1713 | - 085D86042159C72F0037D480 /* ZXVideo.h */, | ||
| 1714 | - 085D86052159C72F0037D480 /* ZXVideoPlayerBrightnessView.m */, | ||
| 1715 | - 085D86062159C72F0037D480 /* ZXVideoPlayerControlView.m */, | ||
| 1716 | - 085D86072159C72F0037D480 /* ZXVideoPlayerController.m */, | ||
| 1717 | 085D86082159C72F0037D480 /* ZXVideoPlayerBatteryView.h */, | 1716 | 085D86082159C72F0037D480 /* ZXVideoPlayerBatteryView.h */, |
| 1717 | + 085D86012159C72F0037D480 /* ZXVideoPlayerBatteryView.m */, | ||
| 1718 | ); | 1718 | ); |
| 1719 | path = Classes; | 1719 | path = Classes; |
| 1720 | sourceTree = "<group>"; | 1720 | sourceTree = "<group>"; |
| @@ -1757,8 +1757,8 @@ | @@ -1757,8 +1757,8 @@ | ||
| 1757 | 085D86982159CBBB0037D480 /* CNLivePlayer */ = { | 1757 | 085D86982159CBBB0037D480 /* CNLivePlayer */ = { |
| 1758 | isa = PBXGroup; | 1758 | isa = PBXGroup; |
| 1759 | children = ( | 1759 | children = ( |
| 1760 | - 085D86992159CBBB0037D480 /* CNLivePlayerController.m */, | ||
| 1761 | 085D869A2159CBBB0037D480 /* CNLivePlayerController.h */, | 1760 | 085D869A2159CBBB0037D480 /* CNLivePlayerController.h */, |
| 1761 | + 085D86992159CBBB0037D480 /* CNLivePlayerController.m */, | ||
| 1762 | ); | 1762 | ); |
| 1763 | path = CNLivePlayer; | 1763 | path = CNLivePlayer; |
| 1764 | sourceTree = "<group>"; | 1764 | sourceTree = "<group>"; |
CNLiveScioLive/Pages/Live/Controller/GraphicLiveViewController.m
| @@ -9,7 +9,7 @@ | @@ -9,7 +9,7 @@ | ||
| 9 | #import "GraphicLiveViewController.h" | 9 | #import "GraphicLiveViewController.h" |
| 10 | #import "OldVideoDetailViewController.h" | 10 | #import "OldVideoDetailViewController.h" |
| 11 | 11 | ||
| 12 | -@interface GraphicLiveViewController () | 12 | +@interface GraphicLiveViewController ()<CNLivePlayerControllerDelegate> |
| 13 | @end | 13 | @end |
| 14 | @implementation GraphicLiveViewController | 14 | @implementation GraphicLiveViewController |
| 15 | - (void)Pop:(id)sender{ | 15 | - (void)Pop:(id)sender{ |
| @@ -192,47 +192,49 @@ | @@ -192,47 +192,49 @@ | ||
| 192 | 192 | ||
| 193 | - (void)shareButton:(UIButton *)btn{ | 193 | - (void)shareButton:(UIButton *)btn{ |
| 194 | NSString *text = [NSString stringWithFormat:@"%@",_dictionary[@"Description"]]; | 194 | NSString *text = [NSString stringWithFormat:@"%@",_dictionary[@"Description"]]; |
| 195 | + NSString *shareUrl = [NSString stringWithFormat:@"%@",_dictionary[@"shareUrl"]]; | ||
| 196 | + | ||
| 195 | if ([text isEqualToString:@"<null>"]) { | 197 | if ([text isEqualToString:@"<null>"]) { |
| 196 | text = _dictionary[@"title"]; | 198 | text = _dictionary[@"title"]; |
| 197 | } | 199 | } |
| 198 | NSMutableDictionary *shareParams = [NSMutableDictionary dictionary]; | 200 | NSMutableDictionary *shareParams = [NSMutableDictionary dictionary]; |
| 199 | [shareParams SSDKSetupShareParamsByText:text | 201 | [shareParams SSDKSetupShareParamsByText:text |
| 200 | images:nil | 202 | images:nil |
| 201 | - url:[NSURL URLWithString:_dictionary[@"pageUrl"]] | 203 | + url:[NSURL URLWithString:shareUrl?shareUrl:@"http://app.scio.gov.cn/gxbShare.html"] |
| 202 | title:_dictionary[@"title"] | 204 | title:_dictionary[@"title"] |
| 203 | type:SSDKContentTypeAuto]; | 205 | type:SSDKContentTypeAuto]; |
| 204 | //2、分享(可以弹出我们的分享菜单和编辑界面) | 206 | //2、分享(可以弹出我们的分享菜单和编辑界面) |
| 205 | - [ShareSDK showShareActionSheet:nil //要显示菜单的视图, iPad版中此参数作为弹出菜单的参照视图,只有传这个才可以弹出我们的分享菜单,可以传分享的按钮对象或者自己创建小的view 对象,iPhone可以传nil不会影响 | ||
| 206 | - items:nil | ||
| 207 | - shareParams:shareParams | ||
| 208 | - onShareStateChanged:^(SSDKResponseState state, SSDKPlatformType platformType, NSDictionary *userData, SSDKContentEntity *contentEntity, NSError *error, BOOL end) { | 207 | + //要显示菜单的视图, iPad版中此参数作为弹出菜单的参照视图,只有传这个才可以弹出我们的分享菜单,可以传分享的按钮对象或者自己创建小的view 对象,iPhone可以传nil不会影响 |
| 208 | + [ShareSDK showShareActionSheet:nil items:nil shareParams:shareParams onShareStateChanged:^(SSDKResponseState state, SSDKPlatformType platformType, NSDictionary *userData, SSDKContentEntity *contentEntity, NSError *error, BOOL end) { | ||
| 209 | 209 | ||
| 210 | - switch (state) { | ||
| 211 | - case SSDKResponseStateSuccess: | ||
| 212 | - { | ||
| 213 | - UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:CustomStr(@"ShareSuccess") | ||
| 214 | - message:nil | ||
| 215 | - delegate:nil | ||
| 216 | - cancelButtonTitle:CustomStr(@"Sure") | ||
| 217 | - otherButtonTitles:nil]; | ||
| 218 | - [alertView show]; | ||
| 219 | - break; | ||
| 220 | - } | ||
| 221 | - case SSDKResponseStateFail: | ||
| 222 | - { | ||
| 223 | - UIAlertView *alert = [[UIAlertView alloc] initWithTitle:CustomStr(@"ShareFailure") | ||
| 224 | - message:[NSString stringWithFormat:@"%@",error] | ||
| 225 | - delegate:nil | ||
| 226 | - cancelButtonTitle:CustomStr(@"Sure") | ||
| 227 | - otherButtonTitles:nil, nil]; | ||
| 228 | - [alert show]; | ||
| 229 | - break; | ||
| 230 | - } | ||
| 231 | - default: | ||
| 232 | - break; | ||
| 233 | - } | ||
| 234 | - } | ||
| 235 | - ]; | 210 | + switch (state) { |
| 211 | + case SSDKResponseStateSuccess: | ||
| 212 | + { | ||
| 213 | + UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:CustomStr(@"ShareSuccess") | ||
| 214 | + message:nil | ||
| 215 | + delegate:nil | ||
| 216 | + cancelButtonTitle:CustomStr(@"Sure") | ||
| 217 | + otherButtonTitles:nil]; | ||
| 218 | + [alertView show]; | ||
| 219 | + break; | ||
| 220 | + } | ||
| 221 | + case SSDKResponseStateFail: | ||
| 222 | + { | ||
| 223 | + UIAlertView *alert = [[UIAlertView alloc] initWithTitle:CustomStr(@"ShareFailure") | ||
| 224 | + message:[NSString stringWithFormat:@"%@",error] | ||
| 225 | + delegate:nil | ||
| 226 | + cancelButtonTitle:CustomStr(@"Sure") | ||
| 227 | + otherButtonTitles:nil, nil]; | ||
| 228 | + [alert show]; | ||
| 229 | + break; | ||
| 230 | + } | ||
| 231 | + default: | ||
| 232 | + break; | ||
| 233 | + | ||
| 234 | + } | ||
| 235 | + | ||
| 236 | + }]; | ||
| 237 | + | ||
| 236 | } | 238 | } |
| 237 | 239 | ||
| 238 | - (void)pausePlayer { | 240 | - (void)pausePlayer { |
| @@ -253,15 +255,12 @@ | @@ -253,15 +255,12 @@ | ||
| 253 | [backButton addTarget:self action:@selector(backButtonAction:) forControlEvents:UIControlEventTouchUpInside]; | 255 | [backButton addTarget:self action:@selector(backButtonAction:) forControlEvents:UIControlEventTouchUpInside]; |
| 254 | [bgView addSubview:backButton]; | 256 | [bgView addSubview:backButton]; |
| 255 | 257 | ||
| 256 | - //////////////// 分享 //////////////// | ||
| 257 | UIButton *shareButton = [UIButton buttonWithType:UIButtonTypeCustom]; | 258 | UIButton *shareButton = [UIButton buttonWithType:UIButtonTypeCustom]; |
| 258 | - shareButton.backgroundColor = [UIColor redColor]; | ||
| 259 | - [shareButton setFrame:CGRectMake(MainScreenWidth-40, StatusBarHeight+7, 30, 30)]; | ||
| 260 | - [shareButton setImage:[UIImage imageNamed:@"cnlive_live_share"] forState:UIControlStateNormal]; | ||
| 261 | [shareButton addTarget:self action:@selector(shareButton:) forControlEvents:UIControlEventTouchUpInside]; | 259 | [shareButton addTarget:self action:@selector(shareButton:) forControlEvents:UIControlEventTouchUpInside]; |
| 260 | + [shareButton setImage:[UIImage imageNamed:@"cnlive_live_share"] forState:UIControlStateNormal]; | ||
| 261 | + [shareButton setFrame:CGRectMake(MainScreenWidth-40, StatusBarHeight+7, 30, 30)]; | ||
| 262 | [bgView addSubview:shareButton]; | 262 | [bgView addSubview:shareButton]; |
| 263 | - //////////////// | ||
| 264 | - | 263 | + |
| 265 | if (self.type == PlayerTypeLiving) { | 264 | if (self.type == PlayerTypeLiving) { |
| 266 | // 直播 | 265 | // 直播 |
| 267 | self.liveController = [[CNLivePlayerController alloc] initLivePlayWithChannelId:_dictionary[@"channelId"] activityId:_dictionary[@"activityId"] anchorStatus:YES authSuccess:^{ | 266 | self.liveController = [[CNLivePlayerController alloc] initLivePlayWithChannelId:_dictionary[@"channelId"] activityId:_dictionary[@"activityId"] anchorStatus:YES authSuccess:^{ |
| @@ -273,6 +272,8 @@ | @@ -273,6 +272,8 @@ | ||
| 273 | } getAnchorStatusResult:^(BOOL result) { | 272 | } getAnchorStatusResult:^(BOOL result) { |
| 274 | NSLog(@"获取主播状态%d", result ? YES : NO); | 273 | NSLog(@"获取主播状态%d", result ? YES : NO); |
| 275 | }]; | 274 | }]; |
| 275 | + self.liveController.delegate = self; | ||
| 276 | + | ||
| 276 | } else { | 277 | } else { |
| 277 | // 点播 | 278 | // 点播 |
| 278 | self.liveController = [[CNLivePlayerController alloc] initVodPlayWithVId:_dictionary[@"playbackId"] authSuccess:^{ | 279 | self.liveController = [[CNLivePlayerController alloc] initVodPlayWithVId:_dictionary[@"playbackId"] authSuccess:^{ |
| @@ -282,6 +283,7 @@ | @@ -282,6 +283,7 @@ | ||
| 282 | } authFailed:^(NSDictionary *errorInfo) { | 283 | } authFailed:^(NSDictionary *errorInfo) { |
| 283 | NSLog(@"初始化点播播放器失败%@", errorInfo); | 284 | NSLog(@"初始化点播播放器失败%@", errorInfo); |
| 284 | }]; | 285 | }]; |
| 286 | + self.liveController.delegate = self; | ||
| 285 | } | 287 | } |
| 286 | [[NSUserDefaults standardUserDefaults] setObject:@0 forKey:@"ZXVideoPlayer_DidLockScreen"]; | 288 | [[NSUserDefaults standardUserDefaults] setObject:@0 forKey:@"ZXVideoPlayer_DidLockScreen"]; |
| 287 | __weak typeof(self) weakSelf = self; | 289 | __weak typeof(self) weakSelf = self; |
| @@ -298,6 +300,10 @@ | @@ -298,6 +300,10 @@ | ||
| 298 | self.liveController.video = video; | 300 | self.liveController.video = video; |
| 299 | } | 301 | } |
| 300 | 302 | ||
| 303 | +- (void)shareButtonCNLivePlayerController:(CNLivePlayerController *)view{ | ||
| 304 | + [self shareButton:nil]; | ||
| 305 | + | ||
| 306 | +} | ||
| 301 | - (void)backButtonAction:(UIButton *)sender { | 307 | - (void)backButtonAction:(UIButton *)sender { |
| 302 | [self.navigationController popViewControllerAnimated:YES]; | 308 | [self.navigationController popViewControllerAnimated:YES]; |
| 303 | } | 309 | } |
CNLiveScioLive/Pages/Tools/CNLivePlayer/CNLivePlayerController.h
| @@ -12,8 +12,17 @@ | @@ -12,8 +12,17 @@ | ||
| 12 | #define kZXVideoPlayerOriginalWidth MIN([UIScreen mainScreen].bounds.size.width, [UIScreen mainScreen].bounds.size.height) | 12 | #define kZXVideoPlayerOriginalWidth MIN([UIScreen mainScreen].bounds.size.width, [UIScreen mainScreen].bounds.size.height) |
| 13 | #define kZXVideoPlayerOriginalHeight (kZXVideoPlayerOriginalWidth * (9.0 / 16.0)) | 13 | #define kZXVideoPlayerOriginalHeight (kZXVideoPlayerOriginalWidth * (9.0 / 16.0)) |
| 14 | 14 | ||
| 15 | +@class CNLivePlayerController; | ||
| 16 | + | ||
| 17 | +@protocol CNLivePlayerControllerDelegate <NSObject> | ||
| 18 | +- (void)shareButtonCNLivePlayerController:(CNLivePlayerController *)view; | ||
| 19 | + | ||
| 20 | +@end | ||
| 21 | + | ||
| 15 | @interface CNLivePlayerController : CNLiveMoviePlayerController | 22 | @interface CNLivePlayerController : CNLiveMoviePlayerController |
| 16 | 23 | ||
| 24 | +@property (nonatomic, weak) id<CNLivePlayerControllerDelegate> delegate; | ||
| 25 | + | ||
| 17 | @property (nonatomic, assign) CGRect frame; | 26 | @property (nonatomic, assign) CGRect frame; |
| 18 | /// video model | 27 | /// video model |
| 19 | @property (nonatomic, strong, readwrite) ZXVideo *video; | 28 | @property (nonatomic, strong, readwrite) ZXVideo *video; |
CNLiveScioLive/Pages/Tools/CNLivePlayer/CNLivePlayerController.m
No preview for this file type
CNLiveScioLive/Pages/Tools/ZXVideoPlayer/Classes/ZXVideoPlayerControlView.h
| @@ -57,6 +57,8 @@ | @@ -57,6 +57,8 @@ | ||
| 57 | @property (nonatomic, strong, readwrite) UILabel *titleLabel; | 57 | @property (nonatomic, strong, readwrite) UILabel *titleLabel; |
| 58 | /// 直播状态 | 58 | /// 直播状态 |
| 59 | @property (nonatomic, assign) int liveStatus; | 59 | @property (nonatomic, assign) int liveStatus; |
| 60 | +///分享 | ||
| 61 | +@property (nonatomic, strong, readwrite) UIButton *shareButton; | ||
| 60 | 62 | ||
| 61 | - (void)animateHide; | 63 | - (void)animateHide; |
| 62 | - (void)animateShow; | 64 | - (void)animateShow; |
CNLiveScioLive/Pages/Tools/ZXVideoPlayer/Classes/ZXVideoPlayerControlView.m
| @@ -74,6 +74,9 @@ static const CGFloat kVideoControlBarAutoFadeOutTimeInterval = 5.0; | @@ -74,6 +74,9 @@ static const CGFloat kVideoControlBarAutoFadeOutTimeInterval = 5.0; | ||
| 74 | // 标题 | 74 | // 标题 |
| 75 | [self.topBar addSubview:self.titleLabel]; | 75 | [self.topBar addSubview:self.titleLabel]; |
| 76 | 76 | ||
| 77 | + // 标题 | ||
| 78 | + [self.topBar addSubview:self.shareButton]; | ||
| 79 | + | ||
| 77 | UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(onTap:)]; | 80 | UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(onTap:)]; |
| 78 | [self addGestureRecognizer:tapGesture]; | 81 | [self addGestureRecognizer:tapGesture]; |
| 79 | 82 | ||
| @@ -387,6 +390,16 @@ static const CGFloat kVideoControlBarAutoFadeOutTimeInterval = 5.0; | @@ -387,6 +390,16 @@ static const CGFloat kVideoControlBarAutoFadeOutTimeInterval = 5.0; | ||
| 387 | return _retryButton; | 390 | return _retryButton; |
| 388 | } | 391 | } |
| 389 | 392 | ||
| 393 | +- (UIButton *)shareButton { | ||
| 394 | + if (!_shareButton) { | ||
| 395 | + _shareButton = [UIButton buttonWithType:UIButtonTypeCustom]; | ||
| 396 | + [_shareButton setFrame:CGRectMake(MainScreenWidth-40, 20, 30, 30)]; | ||
| 397 | + [_shareButton setImage:[UIImage imageNamed:@"cnlive_live_share"] forState:UIControlStateNormal]; | ||
| 398 | + | ||
| 399 | + } | ||
| 400 | + return _shareButton; | ||
| 401 | +} | ||
| 402 | + | ||
| 390 | #pragma mark - setter | 403 | #pragma mark - setter |
| 391 | - (void)setLiveStatus:(int)liveStatus { | 404 | - (void)setLiveStatus:(int)liveStatus { |
| 392 | _liveStatus = liveStatus; | 405 | _liveStatus = liveStatus; |
CNLiveScioLive/Pages/Tools/ZXVideoPlayer/Classes/ZXVideoPlayerController.h
| @@ -13,6 +13,7 @@ | @@ -13,6 +13,7 @@ | ||
| 13 | #define kZXVideoPlayerOriginalWidth MIN([UIScreen mainScreen].bounds.size.width, [UIScreen mainScreen].bounds.size.height) | 13 | #define kZXVideoPlayerOriginalWidth MIN([UIScreen mainScreen].bounds.size.width, [UIScreen mainScreen].bounds.size.height) |
| 14 | #define kZXVideoPlayerOriginalHeight (kZXVideoPlayerOriginalWidth * (9.0 / 16.0)) | 14 | #define kZXVideoPlayerOriginalHeight (kZXVideoPlayerOriginalWidth * (9.0 / 16.0)) |
| 15 | 15 | ||
| 16 | + | ||
| 16 | @interface ZXVideoPlayerController : MPMoviePlayerController | 17 | @interface ZXVideoPlayerController : MPMoviePlayerController |
| 17 | 18 | ||
| 18 | @property (nonatomic, assign) CGRect frame; | 19 | @property (nonatomic, assign) CGRect frame; |
CNLiveScioLive/Pages/Tools/ZXVideoPlayer/Classes/ZXVideoPlayerController.m
No preview for this file type