BGKSYAgoraLinkMicPlayerController.m 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. //
  2. // BGKSYAgoraLinkMicPlayerController.m
  3. // FanweApp
  4. //
  5. // Created by xfg on 2017/2/13.
  6. // Copyright © 2017年 xfg. All rights reserved.
  7. //
  8. #import "BGKSYAgoraLinkMicPlayerController.h"
  9. @interface BGKSYAgoraLinkMicPlayerController ()
  10. @end
  11. @implementation BGKSYAgoraLinkMicPlayerController
  12. - (void)viewDidLoad
  13. {
  14. [super viewDidLoad];
  15. _linkMicBaseController = [[BGKSYAgoraStreamerBaseController alloc] init];
  16. _linkMicBaseController.isApplicant = YES;
  17. [self addChild:_linkMicBaseController inRect:self.view.bounds];
  18. [self.view sendSubviewToBack:_linkMicBaseController.view];
  19. _linkMicBaseController.view.hidden = YES;
  20. }
  21. #pragma mark 开始连麦
  22. /*
  23. * 开始连麦
  24. * applicantId:申请连麦者ID
  25. * responderId:接收连麦者ID
  26. * roomId:房间ID
  27. */
  28. - (void)startLinkMic:(NSString *)applicantId andResponderId:(NSString *)responderId roomId:(NSString *)roomId
  29. {
  30. [_linkMicBaseController startLinkMic:applicantId andResponderId:responderId roomId:roomId];
  31. self.videoContrainerView.hidden = YES;
  32. _linkMicBaseController.view.hidden = NO;
  33. [self.txLivePlayer pause];
  34. __weak typeof(self) ws = self;
  35. _linkMicBaseController.onMyCallStart = ^(int status){
  36. if(status == 200) // 建立连接
  37. {
  38. }
  39. else if(status == 408 || status == 404) // 408:对方无应答 404:呼叫未注册号码,主动停止
  40. {
  41. }
  42. };
  43. _linkMicBaseController.onMyCallStop = ^(int status){
  44. ws.linkMicBaseController.view.hidden = YES;
  45. };
  46. _linkMicBaseController.onMyChannelJoin = ^(int status){
  47. };
  48. }
  49. - (void)reloadPlay
  50. {
  51. [self.txLivePlayer startLivePlay:self.playUrlStr type:PLAY_TYPE_LIVE_RTMP];
  52. }
  53. #pragma mark 停止连麦
  54. /*
  55. * 停止连麦
  56. * applicantId:申请连麦者ID
  57. */
  58. - (void)stopLinkMic:(NSString *)applicantId
  59. {
  60. if (_linkMicBaseController.gPUStreamerKit)
  61. {
  62. [_linkMicBaseController stopLinkMic:applicantId];
  63. self.videoContrainerView.hidden = NO;
  64. [self.txLivePlayer resume];
  65. // [self performSelector:@selector(reloadPlay) withObject:nil afterDelay:1];
  66. }
  67. }
  68. -(void)stopRtmp
  69. {
  70. [super stopRtmp];
  71. [self.txLivePlayer stopPlay];
  72. [self stopLinkMic:_linkMicBaseController.applicantId];
  73. [_linkMicBaseController stopLinkMic:_linkMicBaseController.applicantId];
  74. }
  75. #pragma mark 结束播放
  76. - (void)stopPlay
  77. {
  78. [self.txLivePlayer stopPlay];
  79. [self stopLinkMic:_linkMicBaseController.applicantId];
  80. [_linkMicBaseController stopLinkMic:_linkMicBaseController.applicantId];
  81. }
  82. @end