diff --git a/xplan-ios/Assets.xcassets/Room/AcrossRoomPK/anchor_pk_mute_other.imageset/Contents.json b/xplan-ios/Assets.xcassets/Room/AcrossRoomPK/anchor_pk_mute_other.imageset/Contents.json new file mode 100644 index 00000000..48a3bc29 --- /dev/null +++ b/xplan-ios/Assets.xcassets/Room/AcrossRoomPK/anchor_pk_mute_other.imageset/Contents.json @@ -0,0 +1,22 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x" + }, + { + "filename" : "anchor_pk_mute_other@2x.png", + "idiom" : "universal", + "scale" : "2x" + }, + { + "filename" : "anchor_pk_mute_other@3x.png", + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/xplan-ios/Assets.xcassets/Room/AcrossRoomPK/anchor_pk_mute_other.imageset/anchor_pk_mute_other@2x.png b/xplan-ios/Assets.xcassets/Room/AcrossRoomPK/anchor_pk_mute_other.imageset/anchor_pk_mute_other@2x.png new file mode 100644 index 00000000..5865a542 Binary files /dev/null and b/xplan-ios/Assets.xcassets/Room/AcrossRoomPK/anchor_pk_mute_other.imageset/anchor_pk_mute_other@2x.png differ diff --git a/xplan-ios/Assets.xcassets/Room/AcrossRoomPK/anchor_pk_mute_other.imageset/anchor_pk_mute_other@3x.png b/xplan-ios/Assets.xcassets/Room/AcrossRoomPK/anchor_pk_mute_other.imageset/anchor_pk_mute_other@3x.png new file mode 100644 index 00000000..78fdc75a Binary files /dev/null and b/xplan-ios/Assets.xcassets/Room/AcrossRoomPK/anchor_pk_mute_other.imageset/anchor_pk_mute_other@3x.png differ diff --git a/xplan-ios/Assets.xcassets/Room/AcrossRoomPK/anchor_pk_open_other.imageset/Contents.json b/xplan-ios/Assets.xcassets/Room/AcrossRoomPK/anchor_pk_open_other.imageset/Contents.json new file mode 100644 index 00000000..d3c013cc --- /dev/null +++ b/xplan-ios/Assets.xcassets/Room/AcrossRoomPK/anchor_pk_open_other.imageset/Contents.json @@ -0,0 +1,22 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x" + }, + { + "filename" : "anchor_pk_open_other@2x.png", + "idiom" : "universal", + "scale" : "2x" + }, + { + "filename" : "anchor_pk_open_other@3x.png", + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/xplan-ios/Assets.xcassets/Room/AcrossRoomPK/anchor_pk_open_other.imageset/anchor_pk_open_other@2x.png b/xplan-ios/Assets.xcassets/Room/AcrossRoomPK/anchor_pk_open_other.imageset/anchor_pk_open_other@2x.png new file mode 100644 index 00000000..d1ea6b64 Binary files /dev/null and b/xplan-ios/Assets.xcassets/Room/AcrossRoomPK/anchor_pk_open_other.imageset/anchor_pk_open_other@2x.png differ diff --git a/xplan-ios/Assets.xcassets/Room/AcrossRoomPK/anchor_pk_open_other.imageset/anchor_pk_open_other@3x.png b/xplan-ios/Assets.xcassets/Room/AcrossRoomPK/anchor_pk_open_other.imageset/anchor_pk_open_other@3x.png new file mode 100644 index 00000000..f26a2328 Binary files /dev/null and b/xplan-ios/Assets.xcassets/Room/AcrossRoomPK/anchor_pk_open_other.imageset/anchor_pk_open_other@3x.png differ diff --git a/xplan-ios/Main/RTC/RtcImpl/RtcInterface.h b/xplan-ios/Main/RTC/RtcImpl/RtcInterface.h index 3dbfea3c..51f0fecd 100644 --- a/xplan-ios/Main/RTC/RtcImpl/RtcInterface.h +++ b/xplan-ios/Main/RTC/RtcImpl/RtcInterface.h @@ -19,6 +19,11 @@ NS_ASSUME_NONNULL_BEGIN 静音 */ - (BOOL)muteRemote:(BOOL)mute; +/** + 静音某个用户 + userId: 用户ID + */ +- (BOOL)muteRemote:(BOOL)mute userId:(NSString *)userId; /** 上下麦(说话) */ diff --git a/xplan-ios/Main/RTC/RtcImpl/TRTCRtcImpl.m b/xplan-ios/Main/RTC/RtcImpl/TRTCRtcImpl.m index 78551d2b..036253ef 100644 --- a/xplan-ios/Main/RTC/RtcImpl/TRTCRtcImpl.m +++ b/xplan-ios/Main/RTC/RtcImpl/TRTCRtcImpl.m @@ -100,6 +100,11 @@ return YES; } +- (BOOL)muteRemote:(BOOL)mute userId:(NSString *)userId { + [self.engine muteRemoteAudio:userId mute:mute]; + return YES; +} + - (void)broadcast:(BOOL)on { [self.engine switchRole:on ? TRTCRoleAnchor : TRTCRoleAudience]; if (on) { diff --git a/xplan-ios/Main/RTC/RtcManager.h b/xplan-ios/Main/RTC/RtcManager.h index 34a96391..19507333 100644 --- a/xplan-ios/Main/RTC/RtcManager.h +++ b/xplan-ios/Main/RTC/RtcManager.h @@ -115,6 +115,10 @@ typedef NS_ENUM(NSInteger, BackMusicPlayState) { ///退出跨房通话 - (void)disconnectOtherRoom; +/// 静音某个人 +/// @param userId 用户id +- (void)muteOne:(BOOL)mute userId:(NSString *)userId; + /// 播放背景音乐 /// @param filePath 音频文件的地址 /// @param musicId TRTC自己要的 diff --git a/xplan-ios/Main/RTC/RtcManager.m b/xplan-ios/Main/RTC/RtcManager.m index ac18a0ab..8ff7a01e 100644 --- a/xplan-ios/Main/RTC/RtcManager.m +++ b/xplan-ios/Main/RTC/RtcManager.m @@ -107,6 +107,12 @@ [self.engine disconnectOtherRoom]; } +/// 静音某个人 +/// @param userId 用户id +- (void)muteOne:(BOOL)mute userId:(NSString *)userId { + [self.engine muteRemote:mute userId:userId]; +} + - (void)destory { [self.engine destory]; } diff --git a/xplan-ios/Main/Room/View/AcrossRoomPK/View/SubViews/XPAnchorPKMatchView.h b/xplan-ios/Main/Room/View/AcrossRoomPK/View/SubViews/XPAnchorPKMatchView.h index 953b2d14..5e1115ba 100644 --- a/xplan-ios/Main/Room/View/AcrossRoomPK/View/SubViews/XPAnchorPKMatchView.h +++ b/xplan-ios/Main/Room/View/AcrossRoomPK/View/SubViews/XPAnchorPKMatchView.h @@ -20,7 +20,8 @@ NS_ASSUME_NONNULL_BEGIN - (void)handleMatchTimeOutMessage; ///PK匹配中计时 -- (void)openCountdownWithTime:(long)time; +/// - Parameter startTime: 开始时间 +- (void)openCountdownWithTime:(long)startTime; @end diff --git a/xplan-ios/Main/Room/View/AcrossRoomPK/View/SubViews/XPAnchorPKMatchView.m b/xplan-ios/Main/Room/View/AcrossRoomPK/View/SubViews/XPAnchorPKMatchView.m index ea837830..10181cc4 100644 --- a/xplan-ios/Main/Room/View/AcrossRoomPK/View/SubViews/XPAnchorPKMatchView.m +++ b/xplan-ios/Main/Room/View/AcrossRoomPK/View/SubViews/XPAnchorPKMatchView.m @@ -14,6 +14,7 @@ #import "XPMacro.h" #import "Api+AnchorPk.h" #import "RoomInfoModel.h" +#import "Timestamp.h" @interface XPAnchorPKMatchView() ///host 代理 @@ -136,8 +137,28 @@ } #pragma mark - 倒计时 -- (void)openCountdownWithTime:(long)time { - __block long tempTime = time; //倒计时时间 +- (void)openCountdownWithTime:(long)startTime { + __block long tempTime; + [Timestamp getInternetDateWithSuccess:^(NSTimeInterval timeInterval) { + timeInterval = timeInterval * 1000; + tempTime = (timeInterval - startTime) / 1000; + if (tempTime < 0) { + tempTime = 0; + } + [self handleCountTime:tempTime]; + } failure:^(NSError * _Nonnull error) { + NSDate *datenow = [NSDate date]; + long time2 = (long)([datenow timeIntervalSince1970]*1000); + tempTime = (time2 - startTime) / 1000; + if (tempTime < 0) { + tempTime = 0; + } + [self handleCountTime:tempTime]; + }]; +} + +- (void)handleCountTime:(long)time { + __block long tempTime = time; if (self.timer == nil) { @kWeakify(self); dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0); diff --git a/xplan-ios/Main/Room/View/AnchorPK/View/SubViews/XPAnchorPkPanelView.h b/xplan-ios/Main/Room/View/AnchorPK/View/SubViews/XPAnchorPkPanelView.h index 426bdf13..2f10559e 100644 --- a/xplan-ios/Main/Room/View/AnchorPK/View/SubViews/XPAnchorPkPanelView.h +++ b/xplan-ios/Main/Room/View/AnchorPK/View/SubViews/XPAnchorPkPanelView.h @@ -8,7 +8,7 @@ #import NS_ASSUME_NONNULL_BEGIN -@class XPAnchorPkPanelView, AcrossRoomPKPanelModel; +@class XPAnchorPkPanelView, AcrossRoomPKPanelModel, AttachmentModel; @protocol XPAnchorPkPanelViewDelegate ///展示用户卡片 @@ -33,6 +33,8 @@ NS_ASSUME_NONNULL_BEGIN @property (nonatomic,weak) id delegate; ///重置数据 - (void)resetAcrossPKViewData; +///更新对方麦状态 +- (void)updateOtherMicStatus:(AttachmentModel *)attachment; @end diff --git a/xplan-ios/Main/Room/View/AnchorPK/View/SubViews/XPAnchorPkPanelView.m b/xplan-ios/Main/Room/View/AnchorPK/View/SubViews/XPAnchorPkPanelView.m index 02d1bba6..2480ca35 100644 --- a/xplan-ios/Main/Room/View/AnchorPK/View/SubViews/XPAnchorPkPanelView.m +++ b/xplan-ios/Main/Room/View/AnchorPK/View/SubViews/XPAnchorPkPanelView.m @@ -20,9 +20,11 @@ #import "XCHUDTool.h" #import "AccountInfoStorage.h" #import "NSArray+Safe.h" +#import "RtcManager.h" ///Model #import "UserInfoModel.h" #import "AcrossRoomPKPanelModel.h" +#import "AttachmentModel.h" ///View #import "XPAnchorPKPanelUserView.h" ///Api @@ -117,6 +119,23 @@ self.pkPanelInfo = nil; } +///更新对方麦状态 +- (void)updateOtherMicStatus:(AttachmentModel *)attachment { + NSNumber *micStatus = attachment.data[@"aMicStatus"]; + NSNumber *aUid = attachment.data[@"aUid"]; + self.otherMicButton.selected = !micStatus.boolValue; + [[RtcManager instance] muteOne:!micStatus.boolValue userId:[NSString stringWithFormat:@"%@", aUid]]; + if (!micStatus.boolValue) { + [XCHUDTool showErrorWithMessage:@"主播已关闭对方房间的声音"]; + self.otherMicButton.hidden = NO; + } else { + self.otherMicButton.hidden = YES; + } + if ([self.pkPanelInfo.cUid isEqualToString:[AccountInfoStorage instance].getUid]) { + self.otherMicButton.hidden = NO; + } +} + - (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event { UIView *view = [super hitTest:point withEvent:event]; return view == self?nil:view; @@ -501,8 +520,13 @@ self.otherNickLabel.text = pkPanelInfo.aNick; self.redNickLabel.text = pkPanelInfo.cNick; self.followButton.hidden = [pkPanelInfo.cUid isEqualToString:[AccountInfoStorage instance].getUid]; - self.otherMicButton.hidden = ![pkPanelInfo.cUid isEqualToString:[AccountInfoStorage instance].getUid]; + if (pkPanelInfo.aMicStatus == AnchorPKOtherMicStatus_Close) { + self.otherMicButton.hidden = NO; + } else { + self.otherMicButton.hidden = ![pkPanelInfo.cUid isEqualToString:[AccountInfoStorage instance].getUid]; + } self.otherMicButton.selected = pkPanelInfo.aMicStatus == AnchorPKOtherMicStatus_Close; + [[RtcManager instance] muteOne:pkPanelInfo.aMicStatus == AnchorPKOtherMicStatus_Close userId:pkPanelInfo.aUid]; } else { self.redCountLabel.text = @"0"; self.blueCountLabel.text = @"0"; @@ -524,8 +548,10 @@ #pragma mark - private - (void)onAnchorPkMuteMic:(UIButton *)sender { + if (![self.pkPanelInfo.cUid isEqualToString:[AccountInfoStorage instance].getUid]) { + return; + } [Api anchorPKMuteOtherMic:^(BaseModel * _Nullable data, NSInteger code, NSString * _Nullable msg) { - } micStatus:sender.selected ? @"1" : @"0" roundId:[NSString stringWithFormat:@"%ld", self.pkPanelInfo.roundId] roomUid:self.pkPanelInfo.cUid]; } @@ -696,9 +722,10 @@ - (UIButton *)otherMicButton { if (!_otherMicButton) { _otherMicButton = [[UIButton alloc] init]; - [_otherMicButton setImage:[UIImage imageNamed:@"room_position_mute_Anchor"] forState:UIControlStateNormal]; - [_otherMicButton setImage:[UIImage imageNamed:@"room_position_mute_Anchor"] forState:UIControlStateSelected]; + [_otherMicButton setImage:[UIImage imageNamed:@"anchor_pk_open_other"] forState:UIControlStateNormal]; + [_otherMicButton setImage:[UIImage imageNamed:@"anchor_pk_mute_other"] forState:UIControlStateSelected]; [_otherMicButton addTarget:self action:@selector(onAnchorPkMuteMic:) forControlEvents:UIControlEventTouchUpInside]; + _otherMicButton.hidden = YES; } return _otherMicButton; } diff --git a/xplan-ios/Main/Room/View/BaseUIContainerView/XPRoomFunctionContainerView.m b/xplan-ios/Main/Room/View/BaseUIContainerView/XPRoomFunctionContainerView.m index 5be071ac..f6019bf2 100644 --- a/xplan-ios/Main/Room/View/BaseUIContainerView/XPRoomFunctionContainerView.m +++ b/xplan-ios/Main/Room/View/BaseUIContainerView/XPRoomFunctionContainerView.m @@ -470,10 +470,7 @@ NSDictionary *dict = noti.object; NSNumber *startTime = dict[@"matchPkStartTime"]; self.delegate.getRoomInfo.pkMatchStartTime = [startTime longLongValue]; - NSDate *datenow = [NSDate date]; - long time2 = (long)([datenow timeIntervalSince1970]*1000); - long aTime = (time2 - self.delegate.getRoomInfo.pkMatchStartTime) / 1000; - [self.anchorPKMatchView openCountdownWithTime:aTime]; + [self.anchorPKMatchView openCountdownWithTime:[startTime longValue]]; } } @@ -851,6 +848,7 @@ case Custom_Message_Sub_AnchorPK_Panel://个播PK面板消息 { [self.anchorPKMatchView removeFromSuperview]; + self.delegate.getRoomInfo.pkMatchStartTime = nil; if (!self.anchorPKPanelView.superview) { [self addSubview:self.anchorPKPanelView]; [self.anchorPKPanelView mas_makeConstraints:^(MASConstraintMaker *make) { @@ -907,9 +905,9 @@ [self.anchorPKMatchView handleMatchTimeOutMessage]; } break; - case Custom_Message_Sub_AnchorPK_MuteOtherMic:///PK时禁用对方麦克风 + case Custom_Message_Sub_AnchorPK_MuteOtherMic:///PK时禁用对方声音 { - + [self.anchorPKPanelView updateOtherMicStatus:attachment]; } break; default: @@ -1436,6 +1434,7 @@ self.delegate.getRoomInfo.pkRoomId = nil; self.delegate.getRoomInfo.pkState = nil; self.delegate.getRoomInfo.winUid = nil; + self.delegate.getRoomInfo.pkMatchStartTime = nil; } #pragma mark - 房间贵族小喇叭 @@ -1815,10 +1814,7 @@ make.left.mas_equalTo(0); make.width.height.mas_equalTo(52); }]; - NSDate *datenow = [NSDate date]; - long time2 = (long)([datenow timeIntervalSince1970]*1000); - long aTime = (time2 - self.delegate.getRoomInfo.pkMatchStartTime) / 1000; - [self.anchorPKMatchView openCountdownWithTime:aTime]; + [self.anchorPKMatchView openCountdownWithTime:self.delegate.getRoomInfo.pkMatchStartTime]; } } diff --git a/xplan-ios/Main/Room/View/MoreView/View/XPRoomMoreMenuViewController.m b/xplan-ios/Main/Room/View/MoreView/View/XPRoomMoreMenuViewController.m index 3080c532..b0ece548 100644 --- a/xplan-ios/Main/Room/View/MoreView/View/XPRoomMoreMenuViewController.m +++ b/xplan-ios/Main/Room/View/MoreView/View/XPRoomMoreMenuViewController.m @@ -382,7 +382,12 @@ UIKIT_EXTERN NSString * const kRoomGiftEffectUpdateNotificationKey; case RoomMoreMenuType_Room_Anchor_PK_Open: { if (self.hostDelegate.getRoomInfo.pkMatchStartTime) {//PK匹配中 - [self.presenter requestCancelMatchRandomPK:roomUid]; + TTAlertConfig *config = [[TTAlertConfig alloc] init]; + config.message = @"取消匹配?"; + [TTPopup alertWithConfig:config confirmHandler:^{ + [self.presenter requestCancelMatchRandomPK:roomUid]; + } cancelHandler:^{ + }]; } else { [self dismissViewControllerAnimated:NO completion:nil]; XPAnchorPKSelectTypeController *selectVc = [[XPAnchorPKSelectTypeController alloc] initWithRoomUid:roomUid];