123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602 |
- //
- // MusicRoomDetailViewController.m
- // KulexiuForStudent
- //
- // Created by 王智 on 2022/6/27.
- //
- #import "MusicRoomDetailViewController.h"
- #import "AccompanyArrangeCell.h"
- #import "AccompanyHomeworkCell.h"
- #import "AccompanyRemarkCell.h"
- #import "AccompanyDetailBottomView.h"
- #import "HomeworkDetailModel.h"
- #import "EvaluateDetailModel.h"
- #import "KSChatConversationViewController.h"
- #import "KSGroupConversationController.h"
- #import <WMPlayer.h>
- #import <RecordCheckManager.h>
- #import "KSPremissionAlert.h"
- #import "KSMediaManager.h"
- #import "OnlineClassManager.h"
- #import "MusicRoomCourseInfoCell.h"
- #import "CourseGroupNavView.h"
- #import "HomeworkSubmitAlertView.h"
- @interface MusicRoomDetailViewController ()<UITableViewDelegate,UITableViewDataSource,WMPlayerDelegate>
- {
- WMPlayer *_wmPlayer;
- CGRect _playerFrame;
- }
- @property (nonatomic, strong) CourseGroupNavView *navView;
- @property (nonatomic, strong) UIView *bgView;
- @property (nonatomic, assign) BOOL isRatation;
- @property (nonatomic, strong) UITableView *tableView;
- @property (nonatomic, strong) NSMutableArray *fileArray;
- @property (nonatomic, strong) KSMediaManager *mediaManager;
- @property (nonatomic, strong) HomeworkDetailModel *homeworkModel;
- @property (nonatomic, strong) AccompanyDetailBottomView *bottomView;
- @property (nonatomic, strong) OnlineClassManager *classManager;
- @property (nonatomic, assign) BOOL canModify;
- @property (nonatomic, assign) BOOL isModify; // 是否修改作业
- @property (nonatomic, strong) HomeworkSubmitAlertView *submitAlertView;
- @end
- @implementation MusicRoomDetailViewController
- - (void)viewDidLoad {
- [super viewDidLoad];
- // Do any additional setup after loading the view.
- self.ks_prefersNavigationBarHidden = YES;
- [self configUI];
- self.isModify = NO;
- }
- - (void)viewWillAppear:(BOOL)animated {
- [super viewWillAppear:animated];
- [self requestCourseInfoMessage];
- }
- - (void)requestCourseInfoMessage {
- [self requestHomeworkMessage];
- [self requestRoomConfig];
- }
- - (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"];
- if (self.courseType == MUTIL_COURSE_TYPE_GROUP) {
- self.joinRoomBeforeTime = [result ks_integerValueForKey:@"groupStartTime"];
- self.quitRomeEndTime = [result ks_integerValueForKey:@"groupEndTime"];
- }
- else {
- self.joinRoomBeforeTime = [result ks_integerValueForKey:@"pianoStartTime"];
- self.quitRomeEndTime = [result ks_integerValueForKey:@"pianoEndTime"];
- }
-
- }
- else {
- [LOADING_MANAGER MBShowAUTOHidingInWindow:MESSAGEKEY];
- }
- } faliure:^(NSError * _Nonnull error) {
-
- }];
- }
- - (void)requestHomeworkMessage {
- [KSNetworkingManager homeworkDetailRequest:KS_GET courseId:self.courseId 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.reviewHomework == 1 || self.homeworkModel.decorateHomework == 0) {
- self.canModify = NO;
- }
- else {
- self.canModify = YES;
- }
- 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.actionButton.userInteractionEnabled = YES;
- [self.bottomView.actionButton setTitle:@"进入教室" forState:UIControlStateNormal];
- [self.bottomView.actionButton setBackgroundColor:THEMECOLOR];
- [self.bottomView.actionButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
- }
- }
- - (void)configUI {
- [self.scrollView removeFromSuperview];
-
- UIImage *bgImage = [UIImage imageNamed:@"homework_detail_bg"];
- CGFloat height = bgImage.size.height / bgImage.size.width * KPortraitWidth;
- UIImageView *imageView = [[UIImageView alloc] initWithImage:bgImage];
- imageView.frame = CGRectMake(0, 0, KPortraitWidth, height);
- [self.view addSubview:imageView];
-
- [self.view addSubview:self.navView];
- CGFloat navHeight = [CourseGroupNavView getViewHeight];
- [self.navView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.right.top.mas_equalTo(self.view);
- make.height.mas_equalTo(navHeight);
- }];
-
- [self.view addSubview:self.tableView];
- [self.tableView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.right.mas_equalTo(self.view);
- make.top.mas_equalTo(self.navView.mas_bottom);
- 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;
- }
- #pragma mark --- table data source
- - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
- return 4;
- }
- - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
- if (indexPath.row == 0) {
- MusicRoomCourseInfoCell *cell = [tableView dequeueReusableCellWithIdentifier:@"MusicRoomCourseInfoCell"];
- BOOL isGroup = self.courseType == MUTIL_COURSE_TYPE_GROUP ? YES : NO;
- MJWeakSelf;
- [cell configWithSource:self.homeworkModel isGroup:isGroup chatAction:^(NSString * _Nonnull targetId) {
- [weakSelf chatAction:targetId];
- }];
- return cell;
- }
- else if (indexPath.row == 1) {
- AccompanyArrangeCell *cell = [tableView dequeueReusableCellWithIdentifier:@"AccompanyArrangeCell"];
- BOOL hasArrange = self.homeworkModel.decorateHomework == 1 ? YES : NO;
- [cell configWithHomeworkContent:self.homeworkModel.content hasArrangeHomework:hasArrange];
- return cell;
- }
- else if (indexPath.row == 2) {
- // studentAttachments
- BOOL canDisplay = self.homeworkModel.decorateHomework == 1 ? YES : NO;
- BOOL isExpired = self.homeworkModel.homeworkExpire == 1 ? YES : NO;
- AccompanyHomeworkCell *cell = [tableView dequeueReusableCellWithIdentifier:@"AccompanyHomeworkCell"];
- cell.canSubmit = NO;
- cell.showSubmitButton = self.canModify;
- MJWeakSelf;
- [cell configWithAttachmentArray:self.fileArray canDisplaySubmitView:canDisplay isExpired:isExpired callback:^(HOMEWORKACTION action, NSInteger viewIndex) {
- [weakSelf operationActionWithType:action index: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;
- [cell configWithRemarkMessage:self.homeworkModel.teacherReplied hasEvaluate:hasEvaluate hasSubmitHomework:hasSubmitHomework];
- return cell;
- }
- }
- - (void)chatAction:(NSString *)targetId {
- if ([NSString isEmptyString:targetId]) {
- [LOADING_MANAGER MBShowAUTOHidingInWindow:@"报名未结束,暂无群组"];
- return;
- }
- TUIChatConversationModel *model = [[TUIChatConversationModel alloc] init];
- model.groupID = targetId;
- KSGroupConversationController *ctrl = [[KSGroupConversationController alloc] init];
- ctrl.conversation = model;
- [self.navigationController pushViewController:ctrl animated:YES];
- }
- - (void)operationActionWithType:(HOMEWORKACTION)action index:(NSInteger)viewIndex {
- switch (action) {
- case HOMEWORKACTION_PLAY:
- {
- [self playVideoIndex:viewIndex];
- }
- break;
- case HOMEWORKACTION_DELETE:
- {
- [self deleteVideoIndex:viewIndex];
- }
- break;
- case HOMEWORKACTION_HOMEWOEKPAGE:
- {
- [self.submitAlertView configWithFileArray:self.fileArray];
- [self.submitAlertView showInView:self.view];
- }
- default:
- break;
- }
- }
- #pragma mark --- 上传视频文件
- - (void)uploadVideoWithUrl:(NSString *)videoUrl {
-
- NSURL *uploadFileUrl = [NSURL fileURLWithPath:videoUrl];
- NSData *fileData = [NSData dataWithContentsOfURL:uploadFileUrl];
- NSString *suffix = [NSString stringWithFormat:@".%@",[uploadFileUrl pathExtension]];
- [UPLOAD_MANAGER configWithfilePath:@"/homework/"];
- [UPLOAD_MANAGER videoUpload:fileData fileName:@"video" fileSuffix:suffix progress:^(int64_t bytesWritten, int64_t totalBytes) {
- int progress = (int)(bytesWritten / totalBytes * 100);
- __block NSString *tipsMessage = [NSString stringWithFormat:@"上传中 %d%%",progress];
- dispatch_main_async_safe(^{
- [LOADING_MANAGER.loadingView setDisplayText:tipsMessage];
- });
- } successCallback:^(NSMutableArray * _Nonnull fileUrlArray) {
- [LOADING_MANAGER removeCustomLoading];
- NSString *fileUrl = [fileUrlArray lastObject];
- self.isModify = YES;
- // 删除文件
- [self removeVideoWithPath:videoUrl];
- // 刷新弹窗
- [self evaluateSubmitViewWithSource:fileUrl];
- } faliure:^(NSError * _Nullable error, NSString * _Nullable descMessaeg) {
- [LOADING_MANAGER removeCustomLoading];
- if (![NSString isEmptyString:descMessaeg]) {
- [LOADING_MANAGER MBShowAUTOHidingInWindow:descMessaeg];
- }
- }];
- }
- - (void)evaluateSubmitViewWithSource:(NSString *)fileUrl {
- [self.submitAlertView.sourceArray addObject:fileUrl];
- [self.submitAlertView configWithFileArray:self.submitAlertView.sourceArray];
- }
- - (void)removeVideoWithPath:(NSString *)videoUrl {
- NSFileManager *fileMamager = [NSFileManager defaultManager];
- if ([fileMamager fileExistsAtPath:videoUrl]) {
- [fileMamager removeItemAtPath:videoUrl error:nil];
- }
- }
- // 播放
- - (void)playVideoIndex:(NSInteger)index {
- if (self.fileArray.count > index) {
- NSString *fileUrl = self.fileArray[index];
- [self playVideoWithUrl:fileUrl];
- }
- }
- // 删除
- - (void)deleteVideoIndex:(NSInteger)index {
- if (self.fileArray.count > index) {
- [self.fileArray removeObjectAtIndex:index];
- [self.tableView reloadData];
- }
- self.isModify = YES;
- }
- #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;
- _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];
- }];
- }
- }
- - (void)bottomButtonAction {
-
- [self tryJoinRoom];
- }
- - (void)submitHomeworkAction {
- if (self.isModify == NO) {
- [LOADING_MANAGER MBShowAUTOHidingInWindow:@"请先选择视频文件"];
- return;
- }
- if (self.fileArray.count == 0) {
- [LOADING_MANAGER MBShowAUTOHidingInWindow:@"请选择作业视频"];
- return;
- }
- NSString *attachment = [self.fileArray componentsJoinedByString:@","];
- [LOADING_MANAGER showCustomLoading:@"加载中..."];
- [KSNetworkingManager homeSubmitAction:KS_POST courseScheduleId:self.courseId attachment:attachment success:^(NSDictionary * _Nonnull dic) {
- [LOADING_MANAGER removeCustomLoading];
- if ([dic ks_integerValueForKey:@"code"] == 200 && [dic ks_boolValueForKey:@"status"]) {
- [LOADING_MANAGER MBShowAUTOHidingInWindow:@"作业提交成功"];
- [self removeSubmitAlert];
- [self requestCourseInfoMessage];
- self.isModify = NO;
- }
- else {
- [LOADING_MANAGER MBShowAUTOHidingInWindow:MESSAGEKEY];
- }
- } faliure:^(NSError * _Nonnull error) {
- [LOADING_MANAGER removeCustomLoading];
- }];
- }
- - (void)removeSubmitAlert {
- [self.submitAlertView removeView];
- }
- #pragma mark --- lazying
- - (OnlineClassManager *)classManager {
- if (!_classManager) {
- _classManager = [[OnlineClassManager alloc] init];
- }
- return _classManager;
- }
- - (AccompanyDetailBottomView *)bottomView {
- if (!_bottomView) {
- _bottomView = [AccompanyDetailBottomView shareInstance];
- MJWeakSelf;
- [_bottomView sureAction:^{
- [weakSelf bottomButtonAction];
- }];
- }
- return _bottomView;
- }
- - (UITableView *)tableView {
- if (!_tableView) {
- _tableView = [[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStylePlain];
- _tableView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
- _tableView.backgroundColor = [UIColor clearColor];
- _tableView.delegate = self;
- _tableView.dataSource = self;
- _tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
- _tableView.showsHorizontalScrollIndicator = NO;
- _tableView.showsVerticalScrollIndicator = NO;
- _tableView.rowHeight = UITableViewAutomaticDimension;
- _tableView.estimatedRowHeight = 136.0f;
- [_tableView registerNib:[UINib nibWithNibName:@"MusicRoomCourseInfoCell" bundle:[NSBundle mainBundle]] forCellReuseIdentifier:@"MusicRoomCourseInfoCell"];
- [_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"];
- }
- return _tableView;
- }
- - (NSMutableAttributedString *)getAttrStringWithText:(NSString *)text {
- if (![NSString isEmptyString:text]) {
- NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc] init];
- [paragraphStyle setLineSpacing:6];//调整行间距
- NSMutableAttributedString *attr = [[NSMutableAttributedString alloc] initWithString:text attributes:@{NSParagraphStyleAttributeName:paragraphStyle,NSFontAttributeName:[UIFont systemFontOfSize:16],NSForegroundColorAttributeName:HexRGB(0xffffff)}];
- return attr;
- }
- else {
- return [[NSMutableAttributedString alloc] initWithString:@""];
- }
- }
- - (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 {
- [[UIApplication sharedApplication] openURL:[NSURL URLWithString:UIApplicationOpenSettingsURLString] options:@{} completionHandler:nil];
- }
- - (CourseGroupNavView *)navView {
- if (!_navView) {
- _navView = [CourseGroupNavView sharedInstance];
- MJWeakSelf;
- [_navView configWithNavTitle:@"课程详情" callback:^{
- [weakSelf backAction];
- }];
- }
- return _navView;
- }
- - (HomeworkSubmitAlertView *)submitAlertView {
- if (!_submitAlertView) {
- _submitAlertView = [HomeworkSubmitAlertView sharedInstance];
- MJWeakSelf;
- [_submitAlertView alertActionCallback:^(HOMEWORK_TYPE type, NSMutableArray * _Nonnull fileArray, NSInteger videoIndex) {
- [weakSelf alertAction:type fileArray:fileArray videoIndex:videoIndex];
- }];
- }
- return _submitAlertView;
- }
- - (void)alertAction:(HOMEWORK_TYPE)type fileArray:(NSMutableArray *)fileArray videoIndex:(NSInteger)videoIndex {
- switch (type) {
- case HOMEWORK_TYPE_ADD:
- {
- // 调用相册
- self.mediaManager = [[KSMediaManager alloc] init];
- self.mediaManager.mediaType = MEDIATYPE_VIDEO;
- self.mediaManager.maxPhotoNumber = 1;
- self.mediaManager.baseCtrl = self;
- self.mediaManager.needCropImage = NO;
- MJWeakSelf;
- [self.mediaManager noAlertCallback:^(NSString * _Nullable videoUrl, NSMutableArray * _Nullable imageArray, NSMutableArray * _Nullable imageAsset) {
- NSLog(@"%@", videoUrl);
- // 上传视频
- [weakSelf uploadVideoWithUrl:videoUrl];
- }];
- [self.mediaManager pushImagePickerController];
- }
- break;
- case HOMEWORK_TYPE_SUBMIT:
- {
- [self submitHomeworkAction];
- }
- break;
- case HOMEWORK_TYPE_PLAY:
- {
- if (fileArray.count > videoIndex) {
- NSString *fileUrl = fileArray[videoIndex];
- [self playVideoWithUrl:fileUrl];
- }
- }
- break;
- case HOMEWORK_TYPE_DELETE:
- {
- self.isModify = YES;
- }
- break;
- default:
- break;
- }
- }
- /*
- #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
|