|
@@ -13,12 +13,19 @@
|
|
|
#import "lastFileManager.h"
|
|
|
#import <QuartzCore/QuartzCore.h>
|
|
|
|
|
|
+#import "previewAudioPortraitTopMoreView.h"
|
|
|
+#import "editShareView.h"
|
|
|
+#import "uploadFileRecordViewController.h"
|
|
|
+#import "previewAudioPortraitDetailsView.h"
|
|
|
+
|
|
|
@interface audioPlayerViewController ()<DFPlayerDelegate,DFPlayerDataSource>
|
|
|
|
|
|
@property (nonatomic, strong) UIImageView*bgImageView;//中间图片
|
|
|
@property (nonatomic, strong) UIImageView*playImageView;//
|
|
|
@property (nonatomic, strong) CABasicAnimation *rotationAnimation;
|
|
|
|
|
|
+@property (nonatomic, strong) UILabel *AudioTitleLab;//音乐标题
|
|
|
+
|
|
|
@property (nonatomic, strong)UIButton * playPauseBtn;
|
|
|
@property (nonatomic, strong)UIButton * playNextBtn;
|
|
|
@property (nonatomic, strong)UIButton * playLastBtn;
|
|
@@ -75,6 +82,19 @@
|
|
|
|
|
|
[self setAnchorPoint:CGPointMake(1.0, 0.0) forView:_playImageView];
|
|
|
|
|
|
+ _AudioTitleLab = [[UILabel alloc] init];
|
|
|
+ _AudioTitleLab.textAlignment = NSTextAlignmentCenter;
|
|
|
+ _AudioTitleLab.textColor = [UIColor blackColor];
|
|
|
+ _AudioTitleLab.font = [UIFont systemFontOfSize:18.0];
|
|
|
+ _AudioTitleLab.numberOfLines = 2;
|
|
|
+ [self.view addSubview:_AudioTitleLab];
|
|
|
+ [_AudioTitleLab mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
+ make.top.equalTo(_bgImageView.mas_bottom).offset(15);
|
|
|
+ make.left.mas_equalTo(30);
|
|
|
+ make.right.mas_equalTo(-30);
|
|
|
+ make.height.mas_equalTo(45);
|
|
|
+ }];
|
|
|
+
|
|
|
//底部UI背景
|
|
|
UIImageView* bottombgImageView = [UIImageView new];
|
|
|
bottombgImageView.image = [UIImage imageNamed:@"audioBottomBg"];
|
|
@@ -89,9 +109,44 @@
|
|
|
make.height.mas_equalTo(bottombgH);
|
|
|
}];
|
|
|
|
|
|
+
|
|
|
+ [self initRightUpButtonFun];
|
|
|
[self initDFPlayer];
|
|
|
}
|
|
|
|
|
|
+#pragma mark 右上角按钮
|
|
|
+- (void)initRightUpButtonFun
|
|
|
+{
|
|
|
+ //更多按钮
|
|
|
+ UIButton *morenButton = [[UIButton alloc] init];
|
|
|
+ [morenButton setImage:[UIImage imageNamed:@"nas_preview_more_black"] forState:UIControlStateNormal];
|
|
|
+ morenButton.tag = 1;
|
|
|
+ [morenButton addTarget:self action:@selector(didClickHeadButtonFun:) forControlEvents:UIControlEventTouchUpInside];
|
|
|
+ [self.view addSubview:morenButton];
|
|
|
+
|
|
|
+ [morenButton mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
+ make.centerY.equalTo(self.titleLabel.mas_centerY).offset(0);
|
|
|
+ make.right.mas_equalTo(-16);
|
|
|
+ make.width.mas_equalTo(30);
|
|
|
+ make.height.mas_equalTo(30);
|
|
|
+ }];
|
|
|
+
|
|
|
+ UIButton *shareButton = [[UIButton alloc] init];
|
|
|
+ [shareButton setImage:[UIImage imageNamed:@"nas_preview_share_black"] forState:UIControlStateNormal];
|
|
|
+ shareButton.tag = 2;
|
|
|
+ [shareButton addTarget:self action:@selector(didClickHeadButtonFun:) forControlEvents:UIControlEventTouchUpInside];
|
|
|
+ [self.view addSubview:shareButton];
|
|
|
+
|
|
|
+ [shareButton mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
+ make.centerY.equalTo(self.titleLabel.mas_centerY).offset(0);
|
|
|
+ make.right.equalTo(morenButton.mas_left).offset(-20);
|
|
|
+ make.width.mas_equalTo(30);
|
|
|
+ make.height.mas_equalTo(30);
|
|
|
+ }];
|
|
|
+
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
#pragma mark - 以下代码与DFPlayer库有关
|
|
|
#pragma mark - 初始化DFPlayer
|
|
|
- (void)initDFPlayer{
|
|
@@ -277,6 +332,169 @@
|
|
|
|
|
|
}
|
|
|
|
|
|
+#pragma mark 点击右上角 更多或分享
|
|
|
+- (void)didClickHeadButtonFun:(UIButton*)but
|
|
|
+{
|
|
|
+ NSInteger tag = but.tag;
|
|
|
+ if(tag == 1){
|
|
|
+ previewAudioPortraitTopMoreView *topMoreV = [[previewAudioPortraitTopMoreView alloc] init];
|
|
|
+ [self.view addSubview:topMoreV];
|
|
|
+
|
|
|
+ [topMoreV mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
+ make.top.mas_equalTo(0);
|
|
|
+ make.bottom.mas_equalTo(0);
|
|
|
+ make.right.mas_equalTo(0);
|
|
|
+ make.left.mas_equalTo(0);
|
|
|
+ }];
|
|
|
+
|
|
|
+ KWeakSelf
|
|
|
+ topMoreV.didClickButtonFun = ^(NSInteger tag) {
|
|
|
+ switch (tag) {
|
|
|
+ case 10:
|
|
|
+ [weakSelf gotoDownLoadFileFun];
|
|
|
+ break;
|
|
|
+ case 11:
|
|
|
+ [weakSelf showDeleteAlearViewFun];
|
|
|
+ break;
|
|
|
+ case 12:
|
|
|
+ [weakSelf didClickDetailsFun];
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ };
|
|
|
+ }
|
|
|
+ else if (tag == 2){
|
|
|
+ [self gotoShareViewFun];
|
|
|
+ }
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+#pragma mark 用户点击分享
|
|
|
+- (void)gotoShareViewFun
|
|
|
+{
|
|
|
+ editShareView *editShareV = [[editShareView alloc] init];
|
|
|
+
|
|
|
+ NASFileAudioDataModel *dataModel = _audioOutSidedataArray[_index];
|
|
|
+ editShareV.didSelectListArr = [NSMutableArray arrayWithArray:@[dataModel]];
|
|
|
+ editShareV.shareFileType = @"4";
|
|
|
+
|
|
|
+ [self.view addSubview:editShareV];
|
|
|
+
|
|
|
+ [editShareV mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
+ make.left.mas_equalTo(0);
|
|
|
+ make.right.mas_equalTo(0);
|
|
|
+ make.bottom.mas_equalTo(0);
|
|
|
+ make.top.mas_equalTo(0);
|
|
|
+ }];
|
|
|
+}
|
|
|
+
|
|
|
+#pragma mark 用户点击下载
|
|
|
+- (void)gotoDownLoadFileFun
|
|
|
+{
|
|
|
+ NASFileAudioDataModel *dataModel = _audioOutSidedataArray[_index];
|
|
|
+
|
|
|
+ couldPhoneFileModel* fileModel = [couldPhoneFileModel new];
|
|
|
+ fileModel.fileType = @"audio";
|
|
|
+ fileModel.path = dataModel.path;
|
|
|
+ fileModel.name = dataModel.name;
|
|
|
+ fileModel.length = dataModel.size;
|
|
|
+
|
|
|
+ NSMutableArray *arr = [NSMutableArray new];
|
|
|
+ [arr addObject:fileModel];
|
|
|
+
|
|
|
+ uploadFileRecordViewController *vc = [uploadFileRecordViewController new];
|
|
|
+ [self.navigationController pushViewController:vc animated:YES];
|
|
|
+ vc.isDownloadingType = YES;
|
|
|
+ [vc gotoDownloadFile:arr];
|
|
|
+}
|
|
|
+
|
|
|
+#pragma mark 用户点击删除
|
|
|
+- (void)showDeleteAlearViewFun
|
|
|
+{
|
|
|
+ NSString *titleStr = NSLocalizedString(@"delete_file_title_msg",nil);
|
|
|
+ NSString *tipStr = NSLocalizedString(@"delete_file_tip_msg",nil);
|
|
|
+
|
|
|
+ KWeakSelf
|
|
|
+ ComontAlretViewController *curAlretVC= [[ComontAlretViewController alloc] initWithTiTle:titleStr
|
|
|
+ msg:tipStr
|
|
|
+ imageStr:nil
|
|
|
+ cancelTitle:NSLocalizedString(@"other_cancel",nil)
|
|
|
+ okTitle:NSLocalizedString(@"other_confirm",nil) isOkBtnHighlight:YES
|
|
|
+ didClickOk:^{
|
|
|
+
|
|
|
+ [weakSelf delFileListFun];
|
|
|
+ } didClickCancel:^{
|
|
|
+
|
|
|
+ }];
|
|
|
+
|
|
|
+ curAlretVC.modalPresentationStyle = UIModalPresentationCustom;
|
|
|
+
|
|
|
+ [self presentViewController:curAlretVC animated:YES completion:^{
|
|
|
+ curAlretVC.view.superview.backgroundColor = [UIColor clearColor];
|
|
|
+ }];
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+#pragma mark 删除文件数据
|
|
|
+- (void)delFileListFun
|
|
|
+{
|
|
|
+ NSMutableDictionary*paraDict = [NSMutableDictionary new];
|
|
|
+
|
|
|
+ NSMutableArray *pathArr = [NSMutableArray new];
|
|
|
+ NASFileAudioDataModel *dataModel = _audioOutSidedataArray[_index];
|
|
|
+ [pathArr addObject:dataModel.path];
|
|
|
+
|
|
|
+ [paraDict setValue:pathArr forKey:@"path"];
|
|
|
+
|
|
|
+ [self showNewIndicatorWithCanBack:YES canTouch:NO];
|
|
|
+
|
|
|
+ //NSString*code = [[NSString alloc] initWithFormat:@"delFile?path=%@",paraDict[@"path"]]; //delFile?path=[/storage/emulated/0/Download/IMG_6464.HEIC]
|
|
|
+ KWeakSelf //@"delFile"
|
|
|
+ [[netWorkManager shareInstance] cloudPhonePostCallBackCode:@"delFile" Parameters:paraDict success:^(id _Nonnull responseObject) {
|
|
|
+ [weakSelf removeNewIndicator];
|
|
|
+ SuperModel *model = [[SuperModel alloc] initWithDictionary:responseObject error:nil];
|
|
|
+ if(model && model.status == 0){
|
|
|
+ [[iToast makeText:NSLocalizedString(@"delete_file_suc_msg",nil)] show];
|
|
|
+ [weakSelf didDeleteSucFun:dataModel.path];
|
|
|
+ }
|
|
|
+ else{
|
|
|
+
|
|
|
+ }
|
|
|
+ } failure:^(NSError * _Nonnull error) {
|
|
|
+ [weakSelf removeNewIndicator];
|
|
|
+ }];
|
|
|
+}
|
|
|
+
|
|
|
+#pragma mark 删除成功
|
|
|
+- (void)didDeleteSucFun:(NSString*)path
|
|
|
+{
|
|
|
+ //1.删除最近文件数据
|
|
|
+ [[lastFileManager shareManager] deleteFileInfoWithUrl:path];
|
|
|
+
|
|
|
+ if(_didNeedToRegetDataFun){
|
|
|
+ _didNeedToRegetDataFun();
|
|
|
+ }
|
|
|
+ [self.navigationController popViewControllerAnimated:YES];
|
|
|
+}
|
|
|
+
|
|
|
+#pragma mark 用户点击详情
|
|
|
+- (void)didClickDetailsFun
|
|
|
+{
|
|
|
+ NSMutableArray *pathArr = [NSMutableArray new];
|
|
|
+ NASFileAudioDataModel *dataModel = _audioOutSidedataArray[_index];
|
|
|
+
|
|
|
+ previewAudioPortraitDetailsView *topDetailsV = [[previewAudioPortraitDetailsView alloc] initWithFrame:CGRectZero withData:dataModel];
|
|
|
+ [self.view addSubview:topDetailsV];
|
|
|
+
|
|
|
+ [topDetailsV mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
+ make.top.mas_equalTo(0);
|
|
|
+ make.bottom.mas_equalTo(0);
|
|
|
+ make.right.mas_equalTo(0);
|
|
|
+ make.left.mas_equalTo(0);
|
|
|
+ }];
|
|
|
+}
|
|
|
+
|
|
|
#pragma mark - DFPLayer dataSource
|
|
|
- (NSArray<DFPlayerModel *> *)df_audioDataForPlayer:(DFPlayer *)player{
|
|
|
_dataArray = [NSMutableArray array];
|
|
@@ -449,7 +667,8 @@
|
|
|
{
|
|
|
if(_index < _audioOutSidedataArray.count){
|
|
|
NASFileAudioDataModel* dataModel = _audioOutSidedataArray[_index];
|
|
|
- self.titleLabel.text = dataModel.name;
|
|
|
+ //self.titleLabel.text = dataModel.name;
|
|
|
+ _AudioTitleLab.text = dataModel.name;
|
|
|
|
|
|
}
|
|
|
}
|
|
@@ -509,9 +728,11 @@
|
|
|
// 移除imageView上的动画
|
|
|
[self.bgImageView.layer removeAnimationForKey:@"rotateAnimation"];
|
|
|
|
|
|
- // 可选:如果你需要重置imageView的旋转状态(回到初始位置)
|
|
|
- // 注意:这可能会使动画看起来不连续,因为你是直接设置了layer的transform
|
|
|
- self.bgImageView.layer.transform = CATransform3DIdentity;
|
|
|
+
|
|
|
+ [UIView animateWithDuration:5 animations:^{
|
|
|
+ self.bgImageView.layer.transform = CATransform3DIdentity;
|
|
|
+ }];
|
|
|
+
|
|
|
}
|
|
|
|
|
|
- (void)restartRotatingImage {
|