|
@@ -199,8 +199,13 @@
|
|
|
|
|
|
|
|
|
//下一首按钮
|
|
|
- _playNextBtn = [mgr df_nextBtnWithFrame:CGRectZero image:nextImage superView:self.view block:nil];
|
|
|
+ //_playNextBtn = [mgr df_nextBtnWithFrame:CGRectZero image:nextImage superView:self.view block:nil];
|
|
|
+ _playNextBtn = [[UIButton alloc] init];
|
|
|
[_playNextBtn setImage:[UIImage imageNamed:@"dfplayer_next_none"] forState:UIControlStateDisabled];
|
|
|
+ [_playNextBtn setImage:nextImage forState:UIControlStateNormal];
|
|
|
+ [_playNextBtn addTarget:self action:@selector(playNextButtonFun) forControlEvents:UIControlEventTouchUpInside];
|
|
|
+ [self.view addSubview:_playNextBtn];
|
|
|
+
|
|
|
[_playNextBtn mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
make.centerY.equalTo(_playPauseBtn.mas_centerY).offset(0);
|
|
|
make.height.mas_equalTo(32);
|
|
@@ -209,8 +214,12 @@
|
|
|
}];
|
|
|
|
|
|
//上一首按钮
|
|
|
- _playLastBtn = [mgr df_lastBtnWithFrame:CGRectZero image:lastImage superView:self.view block:nil];
|
|
|
+ //_playLastBtn = [mgr df_lastBtnWithFrame:CGRectZero image:lastImage superView:self.view block:nil];
|
|
|
+ _playLastBtn = [[UIButton alloc] init];
|
|
|
[_playLastBtn setImage:[UIImage imageNamed:@"dfplayer_last_none"] forState:UIControlStateDisabled];
|
|
|
+ [_playLastBtn setImage:lastImage forState:UIControlStateNormal];
|
|
|
+ [_playLastBtn addTarget:self action:@selector(playLastButtonFun) forControlEvents:UIControlEventTouchUpInside];
|
|
|
+ [self.view addSubview:_playLastBtn];
|
|
|
|
|
|
[_playLastBtn mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
make.centerY.equalTo(_playPauseBtn.mas_centerY).offset(0);
|
|
@@ -314,7 +323,7 @@
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-#pragma mark 开始和暂停 按钮点击时间
|
|
|
+#pragma mark 按钮点击 播放模型
|
|
|
- (void)didClickPlayModelButtonFun:(UIButton*)but
|
|
|
{
|
|
|
switch ([DFPlayer sharedPlayer].playMode) {
|
|
@@ -339,6 +348,18 @@
|
|
|
|
|
|
}
|
|
|
|
|
|
+#pragma mark 点击下一首
|
|
|
+- (void)playNextButtonFun
|
|
|
+{
|
|
|
+ [[DFPlayer sharedPlayer] df_next];
|
|
|
+}
|
|
|
+
|
|
|
+#pragma mark 点击上一首
|
|
|
+- (void)playLastButtonFun
|
|
|
+{
|
|
|
+ [[DFPlayer sharedPlayer] df_last];
|
|
|
+}
|
|
|
+
|
|
|
#pragma mark 点击右上角 更多或分享
|
|
|
- (void)didClickHeadButtonFun:(UIButton*)but
|
|
|
{
|
|
@@ -425,7 +446,7 @@
|
|
|
KWeakSelf
|
|
|
ComontAlretViewController *curAlretVC= [[ComontAlretViewController alloc] initWithTiTle:titleStr
|
|
|
msg:tipStr
|
|
|
- imageStr:nil
|
|
|
+ imageStr:@""
|
|
|
cancelTitle:NSLocalizedString(@"other_cancel",nil)
|
|
|
okTitle:NSLocalizedString(@"other_confirm",nil) isOkBtnHighlight:YES
|
|
|
didClickOk:^{
|
|
@@ -489,7 +510,6 @@
|
|
|
#pragma mark 用户点击详情
|
|
|
- (void)didClickDetailsFun
|
|
|
{
|
|
|
- NSMutableArray *pathArr = [NSMutableArray new];
|
|
|
NASFileAudioDataModel *dataModel = _allAudioDataArray[_index];
|
|
|
|
|
|
previewAudioPortraitDetailsView *topDetailsV = [[previewAudioPortraitDetailsView alloc] initWithFrame:CGRectZero withData:dataModel];
|
|
@@ -520,6 +540,21 @@
|
|
|
_audioPlayListV.didClickButtonFun = ^{
|
|
|
[weakSelf gotoAddAudioToPlayListVCFun];
|
|
|
};
|
|
|
+
|
|
|
+ _audioPlayListV.didClickDeleteFun = ^(lastFileModel * _Nonnull dataModel) {
|
|
|
+ [weakSelf deleteAudioToListBy:dataModel];
|
|
|
+ };
|
|
|
+}
|
|
|
+
|
|
|
+#pragma mark 处理本地是否需要添加新加的的音乐
|
|
|
+- (void)deleteAudioToListBy:(lastFileModel*)dataModel
|
|
|
+{
|
|
|
+ [[lastFileManager shareManager] deleteFileInfoWithUrl:dataModel.path];
|
|
|
+ [[audioPlayListManager shareManager] deleteFileInfoWithUrl:dataModel.path];
|
|
|
+
|
|
|
+ [[DFPlayer sharedPlayer] df_reloadData];
|
|
|
+
|
|
|
+ [_audioPlayListV reGetDataFun];
|
|
|
}
|
|
|
|
|
|
#pragma mark 跳转添加音乐到播放列表
|
|
@@ -539,16 +574,53 @@
|
|
|
- (void)AddNewAudioToListFun
|
|
|
{
|
|
|
[[DFPlayer sharedPlayer] df_reloadData];
|
|
|
-
|
|
|
}
|
|
|
|
|
|
+#pragma mark 处理一些UI问题
|
|
|
+- (void)handleSomeUIFun
|
|
|
+{
|
|
|
+ if(_allAudioDataArray.count <= 1){
|
|
|
+ _playLastBtn.enabled = NO;
|
|
|
+ _playNextBtn.enabled = NO;
|
|
|
+ }
|
|
|
+ else{
|
|
|
+ _playLastBtn.enabled = YES;
|
|
|
+ _playNextBtn.enabled = YES;
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
#pragma mark - DFPLayer dataSource
|
|
|
- (NSArray<DFPlayerModel *> *)df_audioDataForPlayer:(DFPlayer *)player{
|
|
|
_dataArray = [NSMutableArray array];
|
|
|
-
|
|
|
_allAudioDataArray = [NSMutableArray array];
|
|
|
+
|
|
|
+ //把播放列表的数据同步进来
|
|
|
+ NSMutableArray *localList = [audioPlayListManager shareManager].audioPlayListArr;
|
|
|
|
|
|
- //首次进来
|
|
|
+ if(localList.count > 0){
|
|
|
+ for (NSInteger i = 0; i < localList.count; i++)
|
|
|
+ {
|
|
|
+ NASFileAudioDataModel *yourModel = localList[i];
|
|
|
+ DFPlayerModel *model = [[DFPlayerModel alloc] init];
|
|
|
+ model.audioId = i;//****重要。AudioId从0开始,仅标识当前音频在数组中的位置。
|
|
|
+
|
|
|
+ NSString *filePath = yourModel.path;
|
|
|
+ NSString *urlStr = ksharedAppDelegate.NASFileByBoxService;
|
|
|
+
|
|
|
+ NSString *filePathBase64 = [iTools base64UrlEncoder:filePath];
|
|
|
+
|
|
|
+ NSString *fileUrl = [[NSString alloc] initWithFormat:@"%@getFiles/%@",urlStr,filePathBase64];
|
|
|
+
|
|
|
+ NSURL * curURL = [NSURL fileURLWithPath:fileUrl];
|
|
|
+ model.audioUrl = curURL;
|
|
|
+ HLog(@"%@",curURL.absoluteString);
|
|
|
+ [_dataArray addObject:model];
|
|
|
+ [_allAudioDataArray addObject:yourModel];
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //首次进来 //需要判断原来的播放列表中是否存在音频
|
|
|
if(_isfirstEnterType){
|
|
|
_isfirstEnterType = NO;
|
|
|
|
|
@@ -556,52 +628,48 @@
|
|
|
NASFileAudioDataModel *yourModel = _outSideDataModel;
|
|
|
DFPlayerModel *model = [[DFPlayerModel alloc] init];
|
|
|
model.audioId = 0;//****重要。AudioId从0开始,仅标识当前音频在数组中的位置。
|
|
|
-
|
|
|
+
|
|
|
NSString *filePath = yourModel.path;
|
|
|
- NSString *urlStr = ksharedAppDelegate.NASFileByBoxService;
|
|
|
|
|
|
- NSString *string = filePath;
|
|
|
- NSString *filePathBase64 = [iTools base64UrlEncoder:string];
|
|
|
+ BOOL isInLocalListType = NO;
|
|
|
|
|
|
- NSString *fileUrl = [[NSString alloc] initWithFormat:@"%@getFiles/%@",urlStr,filePathBase64];
|
|
|
-
|
|
|
- NSURL * curURL = [NSURL fileURLWithPath:fileUrl];
|
|
|
- model.audioUrl = curURL;
|
|
|
- HLog(@"%@",curURL.absoluteString);
|
|
|
- [_dataArray addObject:model];
|
|
|
+ for (NSInteger i = 0; i < localList.count; i++){
|
|
|
+ NASFileAudioDataModel * model = _allAudioDataArray[i];
|
|
|
+ if([model.path isEqualToString:filePath]){
|
|
|
+ isInLocalListType = YES;
|
|
|
+ _index = i;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
- [_allAudioDataArray addObject:yourModel];
|
|
|
- }
|
|
|
-
|
|
|
- //把播放列表的数据同步进来
|
|
|
- NSMutableArray *localList = [audioPlayListManager shareManager].audioPlayListArr;
|
|
|
-
|
|
|
- if(localList.count > 0){
|
|
|
- NSInteger curIndex = _dataArray.count;
|
|
|
- for (NSInteger i = 0; i < localList.count; i++)
|
|
|
- {
|
|
|
- NASFileAudioDataModel *yourModel = localList[i];
|
|
|
- DFPlayerModel *model = [[DFPlayerModel alloc] init];
|
|
|
- model.audioId = i + curIndex;//****重要。AudioId从0开始,仅标识当前音频在数组中的位置。
|
|
|
-
|
|
|
- NSString *filePath = yourModel.path;
|
|
|
+ if(!isInLocalListType){
|
|
|
NSString *urlStr = ksharedAppDelegate.NASFileByBoxService;
|
|
|
|
|
|
- NSString *string = filePath;
|
|
|
- NSString *filePathBase64 = [iTools base64UrlEncoder:string];
|
|
|
+ NSString *filePathBase64 = [iTools base64UrlEncoder:filePath];
|
|
|
|
|
|
NSString *fileUrl = [[NSString alloc] initWithFormat:@"%@getFiles/%@",urlStr,filePathBase64];
|
|
|
|
|
|
NSURL * curURL = [NSURL fileURLWithPath:fileUrl];
|
|
|
model.audioUrl = curURL;
|
|
|
HLog(@"%@",curURL.absoluteString);
|
|
|
- [_dataArray addObject:model];
|
|
|
+ [_dataArray insertObject:model atIndex:0];
|
|
|
+ [_allAudioDataArray insertObject:yourModel atIndex:0];
|
|
|
|
|
|
- [_allAudioDataArray addObject:yourModel];
|
|
|
+ //有数据插入 重新排序audioId
|
|
|
+ for (NSInteger i = 0; i < _dataArray.count; i++) {
|
|
|
+ DFPlayerModel *model = _dataArray[i];
|
|
|
+ model.audioId = i;
|
|
|
+ }
|
|
|
}
|
|
|
+
|
|
|
}
|
|
|
|
|
|
HLog(@"%@ --- %ld",_dataArray,_dataArray.count);
|
|
|
+
|
|
|
+ mainBlock(^{
|
|
|
+ [self handleSomeUIFun];
|
|
|
+ });
|
|
|
+
|
|
|
return [_dataArray copy];
|
|
|
|
|
|
// if ([yourModel.yourUrl hasPrefix:@"http"]) {//网络音频
|