BGOtherPushViewController.m 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. //
  2. // BGOtherPushViewController.m
  3. // BuguLive
  4. //
  5. // Created by Mac on 2021/8/12.
  6. // Copyright © 2021 xfg. All rights reserved.
  7. //
  8. #import "BGOtherPushViewController.h"
  9. #import "BGMD5UTils.h"
  10. #import "PublishLiveViewModel.h"
  11. @interface BGOtherPushViewController ()
  12. @property (weak, nonatomic) IBOutlet UIButton *startBtn;
  13. @property (weak, nonatomic) IBOutlet UILabel *rtmpLabel;
  14. @property (weak, nonatomic) IBOutlet UILabel *contentLabel;
  15. @property(nonatomic, strong) CurrentLiveInfo *currentLiveInfo;
  16. @end
  17. @implementation BGOtherPushViewController
  18. - (void)viewDidLoad {
  19. [super viewDidLoad];
  20. // Do any additional setup after loading the view from its nib.
  21. self.title =ASLocalizedString( @"开播设置");
  22. // CAGradientLayer *gl = [CAGradientLayer layer];
  23. // gl.frame = self.startBtn.bounds;
  24. // gl.startPoint = CGPointMake(0, 0);
  25. // gl.endPoint = CGPointMake(1, 1);
  26. // gl.colors = @[(__bridge id)[UIColor colorWithHexString:@"#9E64FF"].CGColor,(__bridge id)[UIColor colorWithHexString:@"#EF60F6"].CGColor];
  27. // gl.locations = @[@(0.0),@(1.0f)];
  28. // [self.startBtn.layer insertSublayer:gl atIndex:0];
  29. [self.startBtn setBackgroundColor:[UIColor colorWithHexString:@"#9E64FF"]];
  30. [self setupBackBtnWithBlock:^{
  31. [self.navigationController popViewControllerAnimated:YES];
  32. }];
  33. [self requestData];
  34. }
  35. - (void)requestData{
  36. NSMutableDictionary *mDict = [NSMutableDictionary dictionary];
  37. [mDict setObject:@"video" forKey:@"ctl"];
  38. [mDict setObject:@"get_video2" forKey:@"act"];
  39. NSString *MD5String = [NSString stringWithFormat:@"%@%@%@",TXYSdkAppId,[[IMAPlatform sharedInstance].host imUserId],self.room_id];
  40. if (![BGUtils isBlankString:MD5String])
  41. {
  42. [mDict setObject:[NSString stringWithFormat:@"%@",[BGMD5UTils getmd5WithString:MD5String]] forKey:@"sign"];
  43. }
  44. [mDict setObject:@"0" forKey:@"is_vod"]; // 0:观看直播;1:点播
  45. // if (!_privateKeyString.length)
  46. // {
  47. // if ([UIPasteboard generalPasteboard].string.length)
  48. // {
  49. // if ([[[UIPasteboard generalPasteboard].string componentsSeparatedByString:[GTMBase64 decodeBase64:@"8J+UkQ=="]] count] > 1)
  50. // {
  51. // _privateKeyString = [[[UIPasteboard generalPasteboard].string componentsSeparatedByString:[GTMBase64 decodeBase64:@"8J+UkQ=="]] objectAtIndex:1];
  52. // }
  53. // }
  54. // }
  55. //
  56. // if (_privateKeyString.length)
  57. // {
  58. // [mDict setObject:_privateKeyString forKey:@"private_key"];
  59. // [UIPasteboard generalPasteboard].string = @"";
  60. // }
  61. [mDict setObject:self.room_id forKey:@"room_id"];
  62. FWWeakify(self)
  63. [self.httpsManager POSTWithParameters:mDict SuccessBlock:^(NSDictionary *responseJson){
  64. FWStrongify(self)
  65. // status: status=1表示抗议正常进入直播间,status=0表示不能正常进入直播间,status=2表示关闭直播间
  66. if ([responseJson toInt:@"status"] == 1)
  67. {
  68. self.currentLiveInfo = [CurrentLiveInfo mj_objectWithKeyValues:responseJson];
  69. NSArray *rtmpArray = [self.currentLiveInfo.push_rtmp componentsSeparatedByString:@"/"];
  70. NSString *content = rtmpArray.lastObject;
  71. NSString *rtmp = [self.currentLiveInfo.push_rtmp substringWithRange:NSMakeRange(0, self.currentLiveInfo.push_rtmp.length - content.length)];
  72. self.rtmpLabel.text = rtmp;
  73. self.contentLabel.text = content;
  74. }
  75. else {
  76. [[BGHUDHelper sharedInstance] tipMessage:ASLocalizedString(@"获取直播信息失败")];
  77. }
  78. } FailureBlock:^(NSError *error) {
  79. [[BGHUDHelper sharedInstance] tipMessage:error.localizedDescription];
  80. }];
  81. }
  82. - (IBAction)copyRtmpBtnAction:(UIButton *)sender {
  83. [UIPasteboard generalPasteboard].string = self.rtmpLabel.text;
  84. [[BGHUDHelper sharedInstance] tipMessage:ASLocalizedString(@"复制成功")];
  85. }
  86. - (IBAction)copyContentBtnAction:(UIButton *)sender {
  87. [UIPasteboard generalPasteboard].string = self.contentLabel.text;
  88. [[BGHUDHelper sharedInstance] tipMessage:ASLocalizedString(@"复制成功")];
  89. }
  90. - (IBAction)startBtnAction:(UIButton *)sender {
  91. if (self.currentLiveInfo == nil) {
  92. return;
  93. }
  94. NSMutableDictionary *mDict = [NSMutableDictionary dictionary];
  95. [mDict setObject:@"video" forKey:@"ctl"];
  96. [mDict setObject:@"video_cstatus" forKey:@"act"];
  97. [mDict setObject:self.currentLiveInfo.room_id forKey:@"room_id"];
  98. [mDict setObject:@"1" forKey:@"status"];
  99. [mDict setObject:self.currentLiveInfo.group_id forKey:@"group_id"];
  100. [self.httpsManager POSTWithParameters:mDict SuccessBlock:^(NSDictionary *responseJson) {
  101. //开始直播完成,进入直播页面
  102. [self dismissViewControllerAnimated:YES completion:^{
  103. [PublishLiveViewModel beginLiveCenter:self.currentLiveInfo.mj_keyValues];
  104. }];
  105. } FailureBlock:^(NSError *error) {
  106. [[BGHUDHelper sharedInstance] tipMessage:error.localizedDescription];
  107. }];
  108. }
  109. @end