| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133 |
- //
- // PublishLiveViewModel.m
- // BuguLive
- //
- // Created by xfg on 2017/6/8.
- // Copyright © 2017年 xfg. All rights reserved.
- //
- #import "PublishLiveViewModel.h"
- @implementation PublishLiveViewModel
- + (void)beginLive:(NSMutableDictionary *)dict vc:(UIViewController *)vc block:(AppCommonBlock)block
- {
- [[LiveCenterAPIManager sharedInstance] liveCenterAPIOfShowHostLiveOfDic:dict block:^(NSDictionary *responseJson, BOOL finished, NSError *error) {
-
- if (finished && !error && responseJson)
- {
- if (block)
- {
- AppBlockModel *blockModel = [AppBlockModel manager];
- blockModel.retDict = responseJson;
- blockModel.status = 1;
- block(blockModel);
- }
-
- if (!vc)
- {
- [PublishLiveViewModel beginLiveCenter:responseJson];
- }
- else
- {
- UIViewController *rootVC = vc.presentingViewController;
- while (rootVC.presentingViewController)
- {
- rootVC = rootVC.presentingViewController;
- }
-
- [rootVC dismissViewControllerAnimated:YES completion:^{
-
- [PublishLiveViewModel beginLiveCenter:responseJson];
- }];
- }
- }
- else
- {
- if (block)
- {
- block([AppBlockModel manager]);
- }
-
- [FanweMessage alertHUD:[responseJson toString:@"error"]];
- // [PublishLiveViewModel closeLastLive];
- }
- }];
- }
- #pragma mark - 暂时使用,对于异常退出的直播,需要先关闭再开启,不然无法开播
- //+ (void)closeLastLive {
- // //直播结束
- // NSMutableDictionary *mDict = [NSMutableDictionary dictionary];
- // [mDict setObject:@"video" forKey:@"ctl"];
- // [mDict setObject:@"end_video" forKey:@"act"];
- // [mDict setObject:@"11506" forKey:@"room_id"];
- //
- // [[NetHttpsManager manager] POSTWithParameters:mDict SuccessBlock:^(NSDictionary *responseJson) {
- // NSLog(@"%@",responseJson);
- // } FailureBlock:^(NSError *error) {
- // NSLog(@"%@",error.description);
- // }];
- //}
- + (void)beginLiveCenter:(NSDictionary *)dict
- {
- // 开启直播(先API拿直播后台类型) 非悬浮 非小屏幕
- BOOL isSusWindow = false;
- BOOL isSmallScreen = false;
- // 根据实际需求 设置
- // isSusWindow = [[GlobalVariables sharedInstance].appModel.open_pai_module intValue] == 1 ? YES : NO;
- isSusWindow = YES;
- [[LiveCenterManager sharedInstance] showLiveOfAPIResponseJson:dict.mutableCopy isSusWindow:isSusWindow isSmallScreen:isSmallScreen block:^(BOOL finished) {
-
- }];
- }
- + (void)beginVoiceLive:(NSMutableDictionary *)dict vc:(UIViewController *)vc block:(AppCommonBlock)block
- {
- [[LiveCenterAPIManager sharedInstance] liveCenterAPIOfShowHostLiveOfDic:dict block:^(NSDictionary *responseJson, BOOL finished, NSError *error) {
- NSMutableDictionary *tmpDic = [NSMutableDictionary dictionaryWithDictionary:responseJson];
- [tmpDic setObject:@"1" forKey:@"is_voice"];
- responseJson = tmpDic.mutableCopy;
- if (finished && !error && responseJson)
- {
- if (block)
- {
- AppBlockModel *blockModel = [AppBlockModel manager];
- blockModel.retDict = responseJson;
- blockModel.status = 1;
- block(blockModel);
- }
-
- if (!vc)
- {
- [PublishLiveViewModel beginLiveCenter:responseJson];
- }
- else
- {
- UIViewController *rootVC = vc.presentingViewController;
- while (rootVC.presentingViewController)
- {
- rootVC = rootVC.presentingViewController;
- }
-
- [rootVC dismissViewControllerAnimated:YES completion:^{
-
- [PublishLiveViewModel beginLiveCenter:responseJson];
- }];
- }
- }
- else
- {
- if (block)
- {
- block([AppBlockModel manager]);
- }
-
- [FanweMessage alertHUD:[responseJson toString:@"error"]];
- }
- }];
- }
- @end
|