123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563 |
- //
- // VipCouseDetailViewController.m
- // KulexiuForTeacher
- //
- // Created by 王智 on 2024/11/13.
- //
- #import "VipCouseDetailViewController.h"
- #import "AccompanyNavView.h"
- #import "CourseGroupPlanAlertView.h"
- #import "VipCouseInfoCell.h"
- #import "AccompanyEvaluateCell.h"
- #import "AccompanyStudentEvaCell.h"
- #import "AccompanyArrangeCell.h"
- #import "AccompanyHomeworkCell.h"
- #import "AccompanyRemarkCell.h"
- #import "HomeworkDetailModel.h"
- #import "EvaluateDetailModel.h"
- #import "KSChatConversationViewController.h"
- #import <WMPlayer.h>
- #import <RecordCheckManager.h>
- #import "KSPremissionAlert.h"
- #import "OnlineClassManager.h"
- #import "AccompanyDetailBottomView.h"
- @interface VipCouseDetailViewController ()<UITableViewDelegate,UITableViewDataSource,WMPlayerDelegate>
- {
- WMPlayer *_wmPlayer;
- CGRect _playerFrame;
- }
- @property (nonatomic, strong) UIView *bgView;
- @property (nonatomic, assign) BOOL isRatation;
- @property (nonatomic, strong) AccompanyNavView *navView;
- @property (nonatomic, strong) UITableView *tableView;
- @property (nonatomic, strong) HomeworkDetailModel *homeworkModel;
- @property (nonatomic, strong) EvaluateDetailModel *evaluateModel;
- @property (nonatomic, strong) AccompanyDetailBottomView *bottomView;
- @property (nonatomic, strong) CourseGroupPlanAlertView *alertView;
- @property (nonatomic, strong) NSMutableArray *fileArray;
- @property (nonatomic, strong) OnlineClassManager *classManager;
- @end
- @implementation VipCouseDetailViewController
- - (void)viewDidLoad {
- [super viewDidLoad];
- // Do any additional setup after loading the view.
- self.ks_prefersNavigationBarHidden = YES;
- [self configUI];
- }
- - (void)requestCourseInfoMessage {
- [self requestHomeworkMessage];
- [self requestEvaluateMessage];
- [self requestRoomConfig];
- }
- - (void)viewWillAppear:(BOOL)animated {
- [super viewWillAppear:animated];
- [self requestCourseInfoMessage];
- [self configStatusViewColorWhite:YES];
- }
- - (void)viewWillDisappear:(BOOL)animated {
- [super viewWillDisappear:animated];
- [self configStatusViewColorWhite:NO];
- }
- - (void)requestRoomConfig {
- [KSNetworkingManager selectRoomConfigRequest:KS_GET success:^(NSDictionary * _Nonnull dic) {
- if ([dic ks_integerValueForKey:@"code"] == 200 && [dic ks_boolValueForKey:@"status"]) {
- NSDictionary *result = [dic ks_dictionaryValueForKey:@"data"];
- self.joinRoomBeforeTime = [result ks_integerValueForKey:@"practiceStartTime"];
- self.quitRomeEndTime = [result ks_integerValueForKey:@"practiceEndTime"];
- }
- else {
- [LOADING_MANAGER MBShowAUTOHidingInWindow:MESSAGEKEY];
- }
- } faliure:^(NSError * _Nonnull error) {
-
- }];
- }
- - (void)requestHomeworkMessage {
- [KSNetworkingManager homeworkDetailRequest:KS_GET courseId:self.courseId studentId:self.studentId success:^(NSDictionary * _Nonnull dic) {
- if ([dic ks_integerValueForKey:@"code"] == 200 && [dic ks_boolValueForKey:@"status"]) {
- self.homeworkModel = [[HomeworkDetailModel alloc] initWithDictionary:[dic ks_dictionaryValueForKey:@"data"]];
- if (self.homeworkModel.submitHomework == 1) {
- if (![NSString isEmptyString:self.homeworkModel.studentAttachments]) {
- self.fileArray = [NSMutableArray arrayWithArray:[self.homeworkModel.studentAttachments componentsSeparatedByString:@","]];
- }
- else {
- self.fileArray = [NSMutableArray array];
- }
- }
- else {
- self.fileArray = [NSMutableArray array];
- }
- }
- else {
- [LOADING_MANAGER MBShowAUTOHidingInWindow:MESSAGEKEY];
- }
- [self evaluateViewDisplay];
- [self.tableView reloadData];
- } faliure:^(NSError * _Nonnull error) {
-
- }];
- }
- - (void)evaluateViewDisplay {
- if ([self.homeworkModel.courseStatus isEqualToString:@"COMPLETE"]) {
- self.bottomView.hidden = YES;
- UIView *bottomView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, KPortraitWidth, 15)];
- self.tableView.tableFooterView = bottomView;
- }
- else {
- CGFloat bottomHeight = [AccompanyDetailBottomView getViewHeight];
- UIView *bottomView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, KPortraitWidth, bottomHeight)];
- self.tableView.tableFooterView = bottomView;
-
- self.bottomView.hidden = NO;
- self.bottomView.sureButton.userInteractionEnabled = YES;
- [self.bottomView.sureButton setTitle:@"进入教室" forState:UIControlStateNormal];
- [self.bottomView.sureButton setBackgroundColor:THEMECOLOR];
- [self.bottomView.sureButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
- }
- }
- - (void)requestEvaluateMessage {
- [KSNetworkingManager selectRepliedRequest:KS_POST courseGroupId:self.courseGroupId courseScheduleId:self.courseId studentId:self.studentId success:^(NSDictionary * _Nonnull dic) {
- if ([dic ks_integerValueForKey:@"code"] == 200 && [dic ks_boolValueForKey:@"status"]) {
- self.evaluateModel = [[EvaluateDetailModel alloc] initWithDictionary:[dic ks_dictionaryValueForKey:@"data"]];
- }
- else {
- [LOADING_MANAGER MBShowAUTOHidingInWindow:MESSAGEKEY];
- }
- [self.tableView reloadData];
- } faliure:^(NSError * _Nonnull error) {
-
- }];
- }
- - (void)configUI {
- [self.scrollView removeFromSuperview];
- [self.view addSubview:self.navView];
- CGFloat height = [self.navView getViewHeight];
- [self.navView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.right.top.mas_equalTo(self.view);
- make.height.mas_equalTo(height);
- }];
- [self.view addSubview:self.tableView];
- [self.tableView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.right.mas_equalTo(self.view);
- make.top.mas_equalTo(self.view.mas_top).offset(kNaviBarHeight);
- make.bottom.mas_equalTo(self.view.mas_bottom);
- }];
- CGFloat bottomHeight = [AccompanyDetailBottomView getViewHeight];
-
- [self.view addSubview:self.bottomView];
- [self.bottomView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.right.bottom.mas_equalTo(self.view);
- make.height.mas_equalTo(bottomHeight);
- }];
- self.bottomView.hidden = YES;
- }
- - (void)evaluateWithStatusLabel:(UILabel *)statusLabel {
- if ([self.homeworkModel.courseStatus isEqualToString:@"COMPLETE"]) {
- statusLabel.text = @"已结束";
- statusLabel.textColor = HexRGB(0x999999);
- }
- else if ([self.homeworkModel.courseStatus isEqualToString:@"ING"]) {
- statusLabel.text = @"进行中";
- statusLabel.textColor = THEMECOLOR;
- }
- else {
- statusLabel.text = @"未开始";
- statusLabel.textColor = HexRGB(0xff802c);
- }
- }
- #pragma mark --- table data source
- - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
- return 6;
- }
- - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
- if (indexPath.row == 0) {
- VipCouseInfoCell *cell = [tableView dequeueReusableCellWithIdentifier:@"VipCouseInfoCell"];
- [cell configWithSource:self.homeworkModel];
- return cell;
- }
- else if (indexPath.row == 1) {
- AccompanyEvaluateCell *cell = [tableView dequeueReusableCellWithIdentifier:@"AccompanyEvaluateCell"];
- NSString *message = self.evaluateModel.teacherReplied;
- BOOL hasEvaluate = [NSString isEmptyString:self.evaluateModel.teacherReplied] ? NO : YES;
- MJWeakSelf;
- [cell configWithEvaluateMessage:message hasEvaluate:hasEvaluate courseStatus:self.homeworkModel.courseStatus callback:^{
- [weakSelf evaluateCourse];
- }];
- return cell;
- }
- else if (indexPath.row == 2) {
- AccompanyStudentEvaCell *cell = [tableView dequeueReusableCellWithIdentifier:@"AccompanyStudentEvaCell"];
- NSString *message = self.evaluateModel.studentReplied;
- BOOL hasEvaluate = [NSString isEmptyString:self.evaluateModel.studentReplied] ? NO : YES;
- [cell configWithEvaluateMessage:message courseStatus:self.homeworkModel.courseStatus starNum:self.evaluateModel.score hasEvaluate:hasEvaluate];
- return cell;
- }
- else if (indexPath.row == 3) {
- AccompanyArrangeCell *cell = [tableView dequeueReusableCellWithIdentifier:@"AccompanyArrangeCell"];
- BOOL hasArrange = self.homeworkModel.decorateHomework == 1 ? YES : NO;
- MJWeakSelf;
- [cell configWithHomeworkContent:self.homeworkModel.content hasArrangeHomework:hasArrange courseStatus:self.homeworkModel.courseStatus callback:^{
- [weakSelf arrangeHomework];
- }];
- return cell;
- }
- else if (indexPath.row == 4) {
- BOOL hasSubmitHomework = self.homeworkModel.submitHomework == 1 ? YES : NO;
- BOOL isExpired = self.homeworkModel.homeworkExpire == 1 ? YES : NO;
- AccompanyHomeworkCell *cell = [tableView dequeueReusableCellWithIdentifier:@"AccompanyHomeworkCell"];
- MJWeakSelf;
- [cell configWithAttachmentArray:self.fileArray hasSubmit:hasSubmitHomework isExpired:isExpired callback:^(NSInteger viewIndex) {
- [weakSelf playVideoIndex:viewIndex];
- }];
- return cell;
- }
- else {
- AccompanyRemarkCell *cell = [tableView dequeueReusableCellWithIdentifier:@"AccompanyRemarkCell"];
- BOOL hasEvaluate = self.homeworkModel.reviewHomework == 1? YES : NO;
- BOOL hasSubmitHomework = self.homeworkModel.submitHomework == 1 ? YES : NO;
- MJWeakSelf;
- [cell configWithRemarkMessage:self.homeworkModel.teacherReplied hasEvaluate:hasEvaluate hasSubmitHomework:hasSubmitHomework callback:^{
- [weakSelf evaluateHomework];
- }];
- return cell;
- }
- }
- - (void)chatAction {
- if (self.homeworkModel && ![NSString isEmptyString:self.homeworkModel.imUserId]) {
- TUIChatConversationModel *model = [[TUIChatConversationModel alloc] init];
- model.userID = self.homeworkModel.imUserId;
- KSChatConversationViewController *ctrl = [[KSChatConversationViewController alloc] init];
- ctrl.conversation = model;
- [self.navigationController pushViewController:ctrl animated:YES];
- }
- }
- - (void)evaluateCourse {
- if (![self.homeworkModel.courseStatus isEqualToString:@"COMPLETE"]) {
- [LOADING_MANAGER MBShowAUTOHidingInWindow:@"课程结束之后才可以评价哦"];
- return;
- }
-
- self.alertView = [CourseGroupPlanAlertView sharedInstance];
- [self.alertView configWithHeadTitle:@"评价学员" tipsDesc:@"请输入您对本次课程学员表现的评价" sureButtonTitle:@"提交" maxCount:200];
- MJWeakSelf;
- [self.alertView configWithDesc:@"" callback:^(NSString * _Nullable planString) {
- [weakSelf evaluateAction:planString];
- }];
- [self.alertView showInView:self.view];
- }
- - (void)evaluateAction:(NSString *)content {
- if ([NSString isEmptyString:content]) {
- [LOADING_MANAGER MBShowAUTOHidingInWindow:@"请输入评价内容"];
- return;
- }
- [LOADING_MANAGER showHUD];
- [KSNetworkingManager teacherCourseRepliedRequest:KS_POST courseScheduleId:self.courseId courseGroupId:self.courseGroupId studentId:self.studentId teacherReplied:content success:^(NSDictionary * _Nonnull dic) {
- [LOADING_MANAGER removeHUD];
- if ([dic ks_integerValueForKey:@"code"] == 200 && [dic ks_boolValueForKey:@"status"]) {
- [LOADING_MANAGER MBShowAUTOHidingInWindow:@"评价成功"];
- [self requestCourseInfoMessage];
- }
- else {
- [LOADING_MANAGER MBShowAUTOHidingInWindow:MESSAGEKEY];
- }
- } faliure:^(NSError * _Nonnull error) {
- [LOADING_MANAGER removeHUD];
- }];
- }
- - (void)arrangeHomework {
- if (![self.homeworkModel.courseStatus isEqualToString:@"COMPLETE"]) {
- [LOADING_MANAGER MBShowAUTOHidingInWindow:@"课程结束之后才可以布置作业哦~"];
- return;
- }
-
- self.alertView = [CourseGroupPlanAlertView sharedInstance];
- [self.alertView configWithHeadTitle:@"布置作业" tipsDesc:@"请输入本次课程作业内容" sureButtonTitle:@"提交" maxCount:200];
- MJWeakSelf;
- [self.alertView configWithDesc:@"" callback:^(NSString * _Nullable planString) {
- [weakSelf arrangeAction:planString];
- }];
- [self.alertView showInView:self.view];
- }
- - (void)arrangeAction:(NSString *)homeworkContent {
- [LOADING_MANAGER showHUD];
- [KSNetworkingManager homeworkDecorateRequest:KS_POST content:homeworkContent courseScheduleId:self.courseId success:^(NSDictionary * _Nonnull dic) {
- [LOADING_MANAGER removeHUD];
- if ([dic ks_integerValueForKey:@"code"] == 200 && [dic ks_boolValueForKey:@"status"]) {
- [LOADING_MANAGER MBShowAUTOHidingInWindow:@"布置成功"];
- [self requestCourseInfoMessage];
- }
- else {
- [LOADING_MANAGER MBShowAUTOHidingInWindow:MESSAGEKEY];
- }
- } faliure:^(NSError * _Nonnull error) {
- [LOADING_MANAGER removeHUD];
- }];
- }
- // 评价作业
- - (void)evaluateHomework {
- if (self.homeworkModel.decorateHomework == 0) {
- [LOADING_MANAGER MBShowAUTOHidingInWindow:@"您还未布置作业"];
- return;
- }
- else if (self.homeworkModel.submitHomework == 0) {
- [LOADING_MANAGER MBShowAUTOHidingInWindow:@"学生还未提交作业"];
- return;
- }
-
- self.alertView = [CourseGroupPlanAlertView sharedInstance];
- [self.alertView configWithHeadTitle:@"作业点评" tipsDesc:@"请输入您对本次作业的点评" sureButtonTitle:@"提交" maxCount:200];
- MJWeakSelf;
- [self.alertView configWithDesc:@"" callback:^(NSString * _Nullable planString) {
- [weakSelf commentAction:planString];
- }];
- [self.alertView showInView:self.view];
- }
- - (void)commentAction:(NSString *)commentMessage {
- [LOADING_MANAGER showHUD];
- [KSNetworkingManager homeworkReviewRequest:KS_POST courseScheduleId:self.courseId studentId:self.studentId review:commentMessage success:^(NSDictionary * _Nonnull dic) {
- [LOADING_MANAGER removeHUD];
- if ([dic ks_integerValueForKey:@"code"] == 200 && [dic ks_boolValueForKey:@"status"]) {
- [LOADING_MANAGER MBShowAUTOHidingInWindow:@"点评成功"];
- [self requestCourseInfoMessage];
- }
- else {
- [LOADING_MANAGER MBShowAUTOHidingInWindow:MESSAGEKEY];
- }
- } faliure:^(NSError * _Nonnull error) {
- [LOADING_MANAGER removeHUD];
- }];
- }
- - (void)playVideoIndex:(NSInteger)index {
- if (self.fileArray.count > index) {
- NSString *fileUrl = self.fileArray[index];
- [self playVideoWithUrl:fileUrl];
- }
- }
- #pragma mark ------ WMPlayer
- - (void)playVideoWithUrl:(NSString *)fileUrl {
- fileUrl = [fileUrl getUrlEndcodeString];
- _playerFrame = CGRectMake(0, iPhoneXSafeTopMargin, kScreenWidth, kScreenHeight - iPhoneXSafeTopMargin - iPhoneXSafeBottomMargin);
- _wmPlayer = [[WMPlayer alloc] initWithFrame:_playerFrame];
- WMPlayerModel *playModel = [[WMPlayerModel alloc] init];
- playModel.videoURL = [NSURL URLWithString:fileUrl];
- _wmPlayer.playerModel = playModel;
- _wmPlayer.delegate = self;
- _wmPlayer.tintColor = THEMECOLOR;
- _bgView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, kScreenHeight)];
- _bgView.backgroundColor = [UIColor blackColor];
- [[UIApplication sharedApplication].keyWindow addSubview:_bgView];
- [[UIApplication sharedApplication].keyWindow addSubview:_wmPlayer];
- [[UIApplication sharedApplication].keyWindow bringSubviewToFront:_wmPlayer];
-
- [_wmPlayer play];
- }
- - (void)wmplayer:(WMPlayer *)wmplayer clickedCloseButton:(UIButton *)backBtn {
- [wmplayer removePlayer];
- [_bgView removeFromSuperview];
- [self setNeedsStatusBarAppearanceUpdate];
- }
- - (void)wmplayer:(WMPlayer *)wmplayer clickedFullScreenButton:(UIButton *)fullScreenBtn {
- self.isRatation = !self.isRatation;
-
- if (self.isRatation) {
- [wmplayer removeFromSuperview];
- [UIView animateWithDuration:1.0f animations:^{
- wmplayer.transform = CGAffineTransformMakeRotation(M_PI_2);
-
- } completion:^(BOOL finished) {
- wmplayer.frame = CGRectMake(0, iPhoneXSafeTopMargin, kScreenWidth, kScreenHeight - iPhoneXSafeTopMargin - iPhoneXSafeBottomMargin);
- [[UIApplication sharedApplication].keyWindow addSubview:wmplayer];
- [[UIApplication sharedApplication].keyWindow bringSubviewToFront:wmplayer];
- }];
- }
- else {
- [wmplayer removeFromSuperview];
-
- [UIView animateWithDuration:1.0f animations:^{
- // 复原
- wmplayer.transform = CGAffineTransformIdentity;
-
- } completion:^(BOOL finished) {
- wmplayer.frame = CGRectMake(0, iPhoneXSafeTopMargin, kScreenWidth, kScreenHeight - iPhoneXSafeTopMargin - iPhoneXSafeBottomMargin);
- [[UIApplication sharedApplication].keyWindow addSubview:wmplayer];
- [[UIApplication sharedApplication].keyWindow bringSubviewToFront:wmplayer];
- }];
- }
- }
- #pragma mark --- lazying
- - (OnlineClassManager *)classManager {
- if (!_classManager) {
- _classManager = [[OnlineClassManager alloc] init];
- }
- return _classManager;
- }
- - (UITableView *)tableView {
- if (!_tableView) {
- _tableView = [[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStylePlain];
- _tableView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
- _tableView.delegate = self;
- _tableView.dataSource = self;
- _tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
- _tableView.showsVerticalScrollIndicator = NO;
- _tableView.showsHorizontalScrollIndicator = NO;
- _tableView.backgroundColor = [UIColor clearColor];
- _tableView.rowHeight = UITableViewAutomaticDimension;
- [_tableView registerNib:[UINib nibWithNibName:@"VipCouseInfoCell" bundle:[NSBundle mainBundle]] forCellReuseIdentifier:@"VipCouseInfoCell"];
- [_tableView registerNib:[UINib nibWithNibName:@"AccompanyEvaluateCell" bundle:[NSBundle mainBundle]] forCellReuseIdentifier:@"AccompanyEvaluateCell"];
- [_tableView registerNib:[UINib nibWithNibName:@"AccompanyStudentEvaCell" bundle:[NSBundle mainBundle]] forCellReuseIdentifier:@"AccompanyStudentEvaCell"];
- [_tableView registerNib:[UINib nibWithNibName:@"AccompanyArrangeCell" bundle:[NSBundle mainBundle]] forCellReuseIdentifier:@"AccompanyArrangeCell"];
- [_tableView registerNib:[UINib nibWithNibName:@"AccompanyHomeworkCell" bundle:[NSBundle mainBundle]] forCellReuseIdentifier:@"AccompanyHomeworkCell"];
- [_tableView registerNib:[UINib nibWithNibName:@"AccompanyRemarkCell" bundle:[NSBundle mainBundle]] forCellReuseIdentifier:@"AccompanyRemarkCell"];
- _tableView.estimatedRowHeight = 136.0f;
- }
- return _tableView;
- }
- - (AccompanyNavView *)navView {
- if (!_navView) {
- _navView = [AccompanyNavView shareInstance];
- MJWeakSelf;
- [_navView navCallback:^{
- [weakSelf backAction];
- }];
- }
- return _navView;
- }
- - (AccompanyDetailBottomView *)bottomView {
- if (!_bottomView) {
- _bottomView = [AccompanyDetailBottomView shareInstance];
- MJWeakSelf;
- [_bottomView joinroomCallback:^{
- [weakSelf tryJoinRoom];
- }];
- }
- return _bottomView;
- }
- - (void)tryJoinRoom {
-
- NSDateFormatter *dateFormatter = [NSObject getDateformatter];
- [dateFormatter setDateFormat:@"yyyy-MM-dd HH:mm:ss"];
- NSDate *beginDate = [dateFormatter dateFromString:self.homeworkModel.startTime];
- NSDate *endDate = [dateFormatter dateFromString:self.homeworkModel.endTime];
- NSDate *currentDate = [NSDate date];
- NSTimeInterval beginTimeInterval = [beginDate timeIntervalSinceDate:currentDate];
- NSTimeInterval endTimeInterval = [currentDate timeIntervalSinceDate:endDate];
- if (beginTimeInterval <= self.joinRoomBeforeTime * 60 && endTimeInterval < 0) {
- [self joinClassRoom];
- }
- else if (endTimeInterval > 0) {
- [LOADING_MANAGER MBShowAUTOHidingInWindow:@"该课程已结束"];
- }
- else {
- NSString *tipsString = [NSString stringWithFormat:@"课程还未开始,请在上课前%zd分钟进入", self.joinRoomBeforeTime];
- [LOADING_MANAGER MBShowAUTOHidingInWindow:tipsString];
- }
- }
- // 加入房间
- - (void)joinClassRoom {
-
- // 加入房间前判断摄像头和麦克风逻辑
- [RecordCheckManager checkCameraPremissionAvaiableCallback:^(PREMISSIONTYPE type) {
- [self afterCheckCameraCheckMic:type];
- }];
- }
- - (void)afterCheckCameraCheckMic:(PREMISSIONTYPE)cameraType {
- [RecordCheckManager checkMicPermissionAvaiableCallback:^(PREMISSIONTYPE type) {
- if (type == PREMISSIONTYPE_YES && cameraType == PREMISSIONTYPE_YES) {
- // 判断是否进行课前检测
- [self.classManager joinRoomWithId:self.courseId subjectName:self.homeworkModel.subjectName classEndTime:self.homeworkModel.endTime inViewController:self];
- }
- else {
- NSString *content = @"";
- CHECKDEVICETYPE checkType = CHECKDEVICETYPE_BOTH;
- if (cameraType == PREMISSIONTYPE_NO && type == PREMISSIONTYPE_NO) {
- content = @"请开启相机和麦克风访问权限";
- checkType = CHECKDEVICETYPE_BOTH;
- }
- else if (cameraType == PREMISSIONTYPE_NO && type == PREMISSIONTYPE_YES) {
- content = @"请开启相机访问权限";
- checkType = CHECKDEVICETYPE_CAMREA;
- }
- else if (cameraType == PREMISSIONTYPE_YES && type == PREMISSIONTYPE_NO) {
- content = @"请开启麦克风访问权限";
- checkType = CHECKDEVICETYPE_MIC;
- }
- [self showAlertWithMessage:content type:checkType];
- }
- }];
-
- }
- - (void)showAlertWithMessage:(NSString *)message type:(CHECKDEVICETYPE)deviceType {
- [KSPremissionAlert shareInstanceDisplayImage:deviceType message:message showInView:self.view cancel:^{
-
- } confirm:^{
- [self openSettingView];
- }];
-
- }
- - (void)openSettingView {
- if (@available(iOS 10, *)) {
- [[UIApplication sharedApplication] openURL:[NSURL URLWithString:UIApplicationOpenSettingsURLString] options:@{} completionHandler:nil];
- } else {
- [[UIApplication sharedApplication] openURL:[NSURL URLWithString:UIApplicationOpenSettingsURLString]];
- }
- }
- /*
- #pragma mark - Navigation
- // In a storyboard-based application, you will often want to do a little preparation before navigation
- - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
- // Get the new view controller using [segue destinationViewController].
- // Pass the selected object to the new view controller.
- }
- */
- @end
|