123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587 |
- //
- // RecordExamViewController.m
- // MusicGradeExam
- //
- // Created by Kyle on 2020/7/22.
- // Copyright © 2020 DayaMusic. All rights reserved.
- //
- #import "RecordExamViewController.h"
- #import "RecordBodyView.h"
- #import "RecordListCell.h"
- #import "RecordBottomView.h"
- #import "RecordTipsView.h"
- #import "WMPlayer.h"
- #import "SongModel.h"
- #import "KSGuideMaskView.h"
- #import "KSNormalAlertView.h"
- #import "KSVideoRecordViewController.h"
- #import "TZImageManager.h"
- @interface RecordExamViewController ()<UITableViewDelegate, UITableViewDataSource,WMPlayerDelegate>
- {
- WMPlayer *_wmPlayer;
- CGRect _playerFrame;
- }
- @property (nonatomic, assign) BOOL isRatation;
- @property (nonatomic, strong) UIView *bgView;
- @property (nonatomic, strong) RecordBodyView *topView;
- @property (nonatomic, strong) RecordTipsView *tipsView;
- @property (nonatomic, strong) UITableView *tableView;
- @property (nonatomic, strong) RecordBottomView *bottomView;
- @property (nonatomic, strong) NSMutableArray *songArray;
- @property (strong, nonatomic) MBProgressHUD *HUD;
- @property (nonatomic, strong) NSMutableArray *fileUrlArray;
- @property (nonatomic, assign) BOOL hasShowTips;
- @end
- @implementation RecordExamViewController
- - (void)viewDidLoad {
- [super viewDidLoad];
- // Do any additional setup after loading the view.
- self.ks_prefersNavigationBarHidden = YES;
- [self configUI];
- if (self.sourceModel) {
- [self evaluateSource];
- }
- else {
- [self requestData];
- }
- }
- - (void)viewWillAppear:(BOOL)animated {
- [super viewWillAppear:animated];
- [UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleLightContent;
-
- }
- - (void)viewDidDisappear:(BOOL)animated {
- [super viewDidDisappear:animated];
- [UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleDefault;
- if(@available(iOS 13.0, *)){
- [UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleDarkContent;
- }
- }
- - (void)requestData {
- [self showhud];
- [KSRequestManager stuRecordDetailRequest:KS_GET examRegistrationId:self.examRegistrationId success:^(NSDictionary * _Nonnull dic) {
- [self removehub];
- if ([dic integerValueForKey:@"code"] == 200 && [dic boolValueForKey:@"status"]) {
- self.sourceModel = [[RecordExamModel alloc] initWithDictionary:[dic dictionaryValueForKey:@"data"]];
- [self evaluateSource];
- }
- else {
- [self MBPShow:MESSAGEKEY];
- }
- } faliure:^(NSError * _Nonnull error) {
- [self removehub];
- }];
- }
- - (void)evaluateSource {
- if (self.sourceModel == nil) {
- return;
- }
- [self.topView configTime:[NSString stringWithFormat:@"%.0f", self.sourceModel.subTime]];
- [self.tipsView configWithEndTime:self.sourceModel.examEndTime];
- NSData *songDate = [self.sourceModel.songJson dataUsingEncoding:NSUTF8StringEncoding];
- NSArray *listArray = [NSJSONSerialization JSONObjectWithData:songDate options:NSJSONReadingMutableContainers | NSJSONReadingMutableLeaves error:nil];
- NSMutableArray *songList = [NSMutableArray array];
- for (NSDictionary *parm in listArray) {
- SongModel *model = [[SongModel alloc] initWithDictionary:parm];
- [songList addObject:model];
- }
- self.songArray = [NSMutableArray arrayWithArray:songList];
-
- for (NSInteger i = 0; i < self.songArray.count; i++) {
- SongModel *model = self.songArray[i];
- NSString *fileKey = [NSString stringWithFormat:@"%@%@", self.examRegistrationId, model.songName];
- NSDictionary *fileMessage = UserDefault(fileKey);
- if (fileMessage) {
- NSString *remoteUrl = [fileMessage stringValueForKey:@"remoteUrl"];
- [self.fileUrlArray addObject:remoteUrl];
- }
- }
- [self checkSubmitButtonEnable];
- [self.tableView reloadData];
- }
- - (void)configUI {
-
- [self.view addSubview:self.topView];
- [self.topView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.left.right.mas_equalTo(self.view);
- make.height.mas_equalTo(self.view.mas_width).multipliedBy(79.0 / 207).offset(11);
- }];
- [self.view addSubview:self.bottomView];
- [self.bottomView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.right.mas_equalTo(self.view);
- make.bottom.mas_equalTo(self.view.mas_bottomMargin);
- make.height.mas_equalTo(90);
- }];
-
- [self.view addSubview:self.tableView];
- [self.tableView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.right.mas_equalTo(self.view);
- make.top.mas_equalTo(self.topView.mas_bottom);
- make.bottom.mas_equalTo(self.bottomView.mas_top);
- }];
- }
- - (void)viewDidAppear:(BOOL)animated {
- [super viewDidAppear:animated];
-
- if (_hasShowTips == NO) {
- [self addIntroduceView];
- }
- }
- - (void)addIntroduceView {
- _hasShowTips = YES;
- CGRect rect1 = [self.tableView convertRect:self.tableView.tableHeaderView.frame toView:[UIApplication sharedApplication].keyWindow];
- rect1.origin.y -= 50;
- rect1.size.height += 50;
- UIBezierPath *pathOne = [UIBezierPath bezierPathWithRect:rect1];
-
- CGRect rect2 = rect1;
- rect2.size = CGSizeMake(kScreenWidth, 130);
- rect2.origin.y = CGRectGetMaxY(rect1);
- UIBezierPath *pathSecond = [UIBezierPath bezierPathWithRect:rect2];
- NSArray *tipsArray = @[@"请在录播时间内完成视频上传", @"点击上传曲目录播视频"];
- NSArray *bezierArray = @[pathOne,pathSecond];
-
- KSGuideMaskView *guideView = [[KSGuideMaskView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, kScreenHeight)];
- [guideView addTips:tipsArray transparentRect:bezierArray shaperLayerIndex:-1];
- [guideView showMaskViewInView:nil];
- }
- #pragma mark ----- table data source
- - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
- return self.songArray.count;
- }
- - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
- SongModel *model = self.songArray[indexPath.row];
- RecordListCell *cell = [tableView dequeueReusableCellWithIdentifier:@"RecordListCell"];
- MJWeakSelf;
- [cell configCellWithSource:model examRegistrationId:self.examRegistrationId operationCallback:^(RECORDTYPE type, NSString *fileKey) {
- [weakSelf opreationCellType:type fileKey:fileKey index:indexPath.row];
- }];
- return cell;
- }
- - (void)opreationCellType:(RECORDTYPE)type fileKey:(NSString *)fileKey index:(NSInteger)cellIndex {
- if (type == RECORDTYPE_RECORD) { // 录像
- NSMutableArray *songNameArray = [NSMutableArray array];
- for (NSInteger i = 0; i < self.songArray.count; i++) {
- if (i >= cellIndex) {
- // 从选择的开始->后面未录制的添加到待录制里
- SongModel *model = self.songArray[i];
- NSString *fileKey = [NSString stringWithFormat:@"%@%@", self.examRegistrationId, model.songName];
- NSDictionary *fileMessage = UserDefault(fileKey);
- if (fileMessage == nil) {
- [songNameArray addObject:model.songName];
- }
- }
- }
- KSVideoRecordViewController *recordCtrl = [[KSVideoRecordViewController alloc] init];
- recordCtrl.subjectName = self.subjectName;
- recordCtrl.leverName = self.leverName;
- recordCtrl.songMessageArray = songNameArray;
- recordCtrl.singleSongRecordMinutes = self.sourceModel.singleSongRecordMinutes;
- [recordCtrl configTime:self.topView.duration recordFinishBlock:^(VIDEORECORDACTION action, NSMutableArray *videoArray) {
- [self uploadVideoWithVideoArray:videoArray songArray:songNameArray];
- }];
- recordCtrl.modalPresentationStyle = UIModalPresentationFullScreen;
- [self presentViewController:recordCtrl animated:YES completion:nil];
-
- }
- else { // 删除
- [self deleteFileWithKey:fileKey];
- }
- }
- - (void)uploadVideoWithVideoArray:(NSMutableArray *)videoArray songArray:(NSArray *)songArray {
- dispatch_main_async_safe(^{
- [MBProgressHUD ksShowHUDWithText:@"视频处理中..."];
- });
- NSMutableArray *urlArray = [NSMutableArray array];
- NSMutableArray *fileKeyArray = [NSMutableArray array];
- MJWeakSelf;
- for (NSInteger index = 0 ;index < videoArray.count; index++) {
- PHAsset *assset = videoArray[index];
- [[TZImageManager manager] getVideoOutputPathWithAsset:assset presetName:AVAssetExportPresetMediumQuality success:^(NSString *outputPath) {
- NSLog(@"视频导出到本地完成,沙盒路径为:%@",outputPath);
- NSData *outputData = [NSData dataWithContentsOfURL:[NSURL fileURLWithPath:outputPath]]; //压缩后的视频
- NSLog(@"导出后的视频:%@",[NSString stringWithFormat:@"%.2fM",(CGFloat)outputData.length/(1024*1024)]);
- NSString *fileKey = [NSString stringWithFormat:@"%@%@", self.examRegistrationId, songArray[index]];
- [urlArray addObject:outputPath];
- [fileKeyArray addObject:fileKey];
- if (index == videoArray.count - 1) {
- [MBProgressHUD ksHideHUD];
- // 批量上传
- [weakSelf mutilUploadVideoWithUrl:urlArray fileKeyArray:fileKeyArray];
- }
-
- } failure:^(NSString *errorMessage, NSError *error) {
- dispatch_main_async_safe(^{
- [MBProgressHUD ksShowMessage:@"视频导出失败"];
- [MBProgressHUD ksHideHUD];
- });
- }];
- }
-
- }
- - (void)deleteFileWithKey:(NSString *)fileKey {
- NSDictionary *parm = UserDefault(fileKey);
- NSString *localUrl = [parm stringValueForKey:@"localFileUrl"];
- [self removeVideoWithPath:localUrl];
- UserDefaultRemoveObjectForKey(fileKey);
- NSString *remoteUrl = [parm stringValueForKey:@"remoteUrl"];
- [self.fileUrlArray removeObject:remoteUrl];
- [self checkSubmitButtonEnable];
- [self.tableView reloadData];
- }
- - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
- RecordListCell *cell = [tableView cellForRowAtIndexPath:indexPath];
- if (cell.fileMessage) {
- // 播放
- NSString *localUrl = [cell.fileMessage stringValueForKey:@"localFileUrl"];
- if ([[NSFileManager defaultManager] fileExistsAtPath:localUrl]) {
- [self playVideoWithUrl:[NSURL fileURLWithPath:localUrl]];
- }
- else {
- NSString *remoteUrl = [cell.fileMessage stringValueForKey:@"remoteUrl"];
- [self playVideoWithUrl:[NSURL URLWithString:remoteUrl]];
- }
- }
- }
- - (void)checkSubmitButtonEnable {
- if (self.fileUrlArray.count == 0) {
- self.bottomView.finishButton.userInteractionEnabled = NO;
- [self.bottomView.finishButton setBackgroundImage:[UIImage imageNamed:@"button_unable"] forState:UIControlStateNormal];
- }
- else {
- self.bottomView.finishButton.userInteractionEnabled = YES;
- [self.bottomView.finishButton setBackgroundImage:[UIImage imageNamed:@"button_nomal"] forState:UIControlStateNormal];
- [self.bottomView.finishButton setBackgroundImage:[UIImage imageNamed:@"button_highlight"] forState:UIControlStateHighlighted];
- }
- }
- #pragma mark --- lazying
- - (RecordBodyView *)topView {
- if (!_topView) {
- _topView = [RecordBodyView shareInstance];
- _topView.topTitleLabel.text = @"录播考试";
- MJWeakSelf;
- [_topView topviewAction:^(RECORDTOPACTION action) {
- [weakSelf backOrEndAction:action];
- }];
- }
- return _topView;
- }
- - (void)backOrEndAction:(RECORDTOPACTION)action {
- if (action == RECORDTOPACTION_BACK) {
- [self.navigationController popViewControllerAnimated:YES];
- }
- else { // 时间结束
- MJWeakSelf;
- if (self.fileUrlArray.count == 0) {
- [self KSShowMsg:@"考试结束" promptCompletion:^{
- [weakSelf.navigationController popViewControllerAnimated:YES];
- }];
- }
- else {
- [KSNormalAlertView ks_showAlertWithTitle:@"考试时间已结束,是否提交?" leftTitle:@"取消" rightTitle:@"确定" cancel:^{
- [weakSelf removeAllFile];
- [weakSelf.navigationController popViewControllerAnimated:YES];
- } confirm:^{
- [weakSelf submitService];
- }];
- }
- }
- }
- - (RecordTipsView *)tipsView {
- if (!_tipsView) {
- _tipsView = [RecordTipsView shareInstance];
- }
- return _tipsView;
- }
- - (UITableView *)tableView {
- if (!_tableView) {
- _tableView = [[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStylePlain];
- _tableView.delegate = self;
- _tableView.dataSource = self;
- _tableView.rowHeight = 130;
- _tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
- _tableView.backgroundColor = HexRGB(0xf5f5f5);
- _tableView.showsVerticalScrollIndicator = NO;
- [_tableView registerNib:[UINib nibWithNibName:@"RecordListCell" bundle:nil] forCellReuseIdentifier:@"RecordListCell"];
- _tableView.tableHeaderView = self.tipsView;
-
- UIView *bottomView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, 10)];
- bottomView.backgroundColor = HexRGB(0xf3f4f8);
- _tableView.tableFooterView = bottomView;
- }
- return _tableView;
- }
- - (RecordBottomView *)bottomView {
- if (!_bottomView) {
- _bottomView = [RecordBottomView shareInstance];
- MJWeakSelf;
- [_bottomView submitMediaAction:^{
- [weakSelf submitAction];
- }];
- }
- return _bottomView;
- }
- - (void)submitAction {
-
- // 是否确认提交
- MJWeakSelf;
- [KSNormalAlertView ks_showAlertWithTitle:@"请确认已上传所有录播曲目" leftTitle:@"取消" rightTitle:@"确认" cancel:^{
-
- } confirm:^{
- [weakSelf submitService];
- }];
-
- }
- // // 提交 完成考试
- - (void)submitService {
- [self showhud];
- NSString *videoUrl = [self.fileUrlArray componentsJoinedByString:@","];
- [KSRequestManager stuEndRecordFinishRequest:KS_POST examRegistrationId:self.examRegistrationId videoUrl:videoUrl success:^(NSDictionary * _Nonnull dic) {
- [self removehub];
- if ([dic integerValueForKey:@"code"] == 200 && [dic boolValueForKey:@"status"]) {
- MJWeakSelf;
- [self removeAllFile];
- [self KSShowMsg:@"提交成功" promptCompletion:^{
- [weakSelf.topView stopDurationTimer];
- [weakSelf.navigationController popViewControllerAnimated:YES];
- }];
- }
- else {
- [self MBPShow:MESSAGEKEY];
- }
- } faliure:^(NSError * _Nonnull error) {
- [self removehub];
- }];
- }
- - (void)removeAllFile {
- for (NSInteger i = 0; i < self.songArray.count; i++) {
- SongModel *model = self.songArray[i];
- NSString *fileKey = [NSString stringWithFormat:@"%@%@", self.examRegistrationId, model.songName];
- NSDictionary *fileMessage = UserDefault(fileKey);
- if (fileMessage) {
- NSString *localUrl = [fileMessage stringValueForKey:@"localFileUrl"];
- UserDefaultRemoveObjectForKey(fileKey);
- [self removeVideoWithPath:localUrl];
- }
- }
- }
- #pragma mark ------ 上传视频文件
- - (void)mutilUploadVideoWithUrl:(NSMutableArray *)videoUrlArray fileKeyArray:(NSMutableArray *)fileKeyArray {
- [self hudTipWillShow:YES];
- NSMutableArray *fileDataArray = [NSMutableArray array];
- for (NSString *videoUrl in videoUrlArray) {
- [fileDataArray addObject:[NSData dataWithContentsOfURL:[NSURL fileURLWithPath:videoUrl]]];
- }
- [KSRequestManager mutiVideoFileUpload:KS_POST fileDataArray:fileDataArray progress:^(int64_t bytesWritten, int64_t totalBytes) {
- dispatch_main_async_safe(^{
- // 显示进度
- if (self.HUD) {
- self.HUD.progress = bytesWritten / totalBytes;// progress是回调进度
- }
- });
-
- } success:^(NSArray * _Nonnull dics) {
- [self hudTipWillShow:NO];
- for (NSInteger index = 0; index < dics.count; index++) {
- NSDictionary *dic = [dics objectAtIndex:index];
- if ([dic integerValueForKey:@"code"] == 200 && [dic boolValueForKey:@"status"]) {
- NSString *fileUrl = [[dic dictionaryValueForKey:@"data"] stringValueForKey:@"url"];
- NSString *fileName = [[fileUrl componentsSeparatedByString:@"/"] lastObject];
- NSString *videoUrl = [fileDataArray objectAtIndex:index];
- NSString *fileKey = [fileKeyArray objectAtIndex:index];
- // 保存文件路径
- NSDictionary *parm = @{@"localFileUrl":videoUrl,
- @"remoteUrl":fileUrl,
- @"fileName": fileName};
- UserDefaultSet(parm, fileKey);
- [self.fileUrlArray addObject:fileUrl];
- [self checkSubmitButtonEnable];
- }
- else {
- [self MBPShow:MESSAGEKEY];
- }
- }
- [self.tableView reloadData];
-
- } faliure:^(NSError * _Nonnull error) {
- [self hudTipWillShow:NO];
- }];
- }
- - (void)uploadVideoWithUrl:(NSString *)videoUrl fileKey:(NSString *)fileKey {
- [self hudTipWillShow:YES];
-
- NSData *fileData = [NSData dataWithContentsOfURL:[NSURL fileURLWithPath:videoUrl]];
- [KSRequestManager videoFileUpload:KS_POST fileData:fileData progress:^(int64_t bytesWritten, int64_t totalBytes) {
- dispatch_main_async_safe(^{
- // 显示进度
- if (self.HUD) {
- self.HUD.progress = bytesWritten / totalBytes;// progress是回调进度
- }
- });
- } success:^(NSDictionary * _Nonnull dic) {
- [self hudTipWillShow:NO];
- if ([dic integerValueForKey:@"code"] == 200 && [dic boolValueForKey:@"status"]) {
- NSString *fileUrl = [[dic dictionaryValueForKey:@"data"] stringValueForKey:@"url"];
- NSString *fileName = [[fileUrl componentsSeparatedByString:@"/"] lastObject];
- // 保存文件路径
- NSDictionary *parm = @{@"localFileUrl":videoUrl,
- @"remoteUrl":fileUrl,
- @"fileName": fileName};
- UserDefaultSet(parm, fileKey);
- [self.tableView reloadData];
-
- [self.fileUrlArray addObject:fileUrl];
- [self checkSubmitButtonEnable];
- }
- else {
- [self MBPShow:MESSAGEKEY];
-
- }
- } faliure:^(NSError * _Nonnull error) {
- [self hudTipWillShow:NO];
- }];
-
- }
- - (void)removeVideoWithPath:(NSString *)videoUrl {
- NSFileManager *fileMamager = [NSFileManager defaultManager];
- if ([fileMamager fileExistsAtPath:videoUrl]) {
- [fileMamager removeItemAtPath:videoUrl error:nil];
- }
- }
- - (void)hudTipWillShow:(BOOL)willShow{
- if (willShow) {
- [self resignFirstResponder];
- UIWindow *keyWindow = [UIApplication sharedApplication].keyWindow;
- if (!_HUD) {
- _HUD = [MBProgressHUD showHUDAddedTo:keyWindow animated:YES];
- _HUD.mode = MBProgressHUDModeDeterminateHorizontalBar;
- _HUD.label.text = @"正在转码视频...";
- _HUD.removeFromSuperViewOnHide = YES;
- }else{
- _HUD.progress = 0;
- [keyWindow addSubview:_HUD];
- [_HUD showAnimated:YES];
- }
- }else{
- [_HUD hideAnimated:YES];
- }
- }
- - (NSMutableArray *)fileUrlArray {
- if (!_fileUrlArray) {
- _fileUrlArray = [NSMutableArray arrayWithCapacity:self.songArray.count];
- }
- return _fileUrlArray;
- }
- #pragma mark ------- 播放文件
- - (void)playVideoWithUrl:(NSURL *)fileUrl {
- _playerFrame = CGRectMake(0, iPhoneXSafeTopMargin, kScreenWidth, kScreenHeight - iPhoneXSafeTopMargin - iPhoneXSafeBottomMargin);
- _wmPlayer = [[WMPlayer alloc] initWithFrame:_playerFrame];
- WMPlayerModel *playModel = [[WMPlayerModel alloc] init];
- playModel.videoURL = 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)dealloc {
- [self.topView stopDurationTimer];
- }
- /*
- #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
|