|
@@ -9,7 +9,6 @@
|
|
|
#import "DFPlayer.h"
|
|
#import "DFPlayer.h"
|
|
|
#import "DFPlayerUIManager.h"
|
|
#import "DFPlayerUIManager.h"
|
|
|
|
|
|
|
|
-#import "NASFileAudioModel.h"
|
|
|
|
|
#import "lastFileManager.h"
|
|
#import "lastFileManager.h"
|
|
|
#import "audioPlayListManager.h"
|
|
#import "audioPlayListManager.h"
|
|
|
#import <QuartzCore/QuartzCore.h>
|
|
#import <QuartzCore/QuartzCore.h>
|
|
@@ -36,6 +35,9 @@
|
|
|
@property (nonatomic, strong)UIButton * playListBtn;//歌单
|
|
@property (nonatomic, strong)UIButton * playListBtn;//歌单
|
|
|
@property (nonatomic, strong)UIButton * playModelBtn;//播放模式(单机 随机 循环)
|
|
@property (nonatomic, strong)UIButton * playModelBtn;//播放模式(单机 随机 循环)
|
|
|
|
|
|
|
|
|
|
+@property (nonatomic, assign) NSInteger index;//当前位置
|
|
|
|
|
+@property (nonatomic, strong) NSMutableArray * allAudioDataArray;//所有的 播放数据(NASFileAudioDataModel或者lastFileModel)
|
|
|
|
|
+
|
|
|
@property (nonatomic, strong) NSMutableArray<DFPlayerModel *> *dataArray;
|
|
@property (nonatomic, strong) NSMutableArray<DFPlayerModel *> *dataArray;
|
|
|
@property (nonatomic, assign) NSInteger lastAudioIndex;//-1未记录
|
|
@property (nonatomic, assign) NSInteger lastAudioIndex;//-1未记录
|
|
|
|
|
|
|
@@ -380,7 +382,7 @@
|
|
|
{
|
|
{
|
|
|
editShareView *editShareV = [[editShareView alloc] init];
|
|
editShareView *editShareV = [[editShareView alloc] init];
|
|
|
|
|
|
|
|
- NASFileAudioDataModel *dataModel = _audioOutSidedataArray[_index];
|
|
|
|
|
|
|
+ NASFileAudioDataModel *dataModel = _allAudioDataArray[_index];
|
|
|
editShareV.didSelectListArr = [NSMutableArray arrayWithArray:@[dataModel]];
|
|
editShareV.didSelectListArr = [NSMutableArray arrayWithArray:@[dataModel]];
|
|
|
editShareV.shareFileType = @"4";
|
|
editShareV.shareFileType = @"4";
|
|
|
|
|
|
|
@@ -397,7 +399,7 @@
|
|
|
#pragma mark 用户点击下载
|
|
#pragma mark 用户点击下载
|
|
|
- (void)gotoDownLoadFileFun
|
|
- (void)gotoDownLoadFileFun
|
|
|
{
|
|
{
|
|
|
- NASFileAudioDataModel *dataModel = _audioOutSidedataArray[_index];
|
|
|
|
|
|
|
+ NASFileAudioDataModel *dataModel = _allAudioDataArray[_index];
|
|
|
|
|
|
|
|
couldPhoneFileModel* fileModel = [couldPhoneFileModel new];
|
|
couldPhoneFileModel* fileModel = [couldPhoneFileModel new];
|
|
|
fileModel.fileType = @"audio";
|
|
fileModel.fileType = @"audio";
|
|
@@ -447,7 +449,7 @@
|
|
|
NSMutableDictionary*paraDict = [NSMutableDictionary new];
|
|
NSMutableDictionary*paraDict = [NSMutableDictionary new];
|
|
|
|
|
|
|
|
NSMutableArray *pathArr = [NSMutableArray new];
|
|
NSMutableArray *pathArr = [NSMutableArray new];
|
|
|
- NASFileAudioDataModel *dataModel = _audioOutSidedataArray[_index];
|
|
|
|
|
|
|
+ NASFileAudioDataModel *dataModel = _allAudioDataArray[_index];
|
|
|
[pathArr addObject:dataModel.path];
|
|
[pathArr addObject:dataModel.path];
|
|
|
|
|
|
|
|
[paraDict setValue:pathArr forKey:@"path"];
|
|
[paraDict setValue:pathArr forKey:@"path"];
|
|
@@ -488,7 +490,7 @@
|
|
|
- (void)didClickDetailsFun
|
|
- (void)didClickDetailsFun
|
|
|
{
|
|
{
|
|
|
NSMutableArray *pathArr = [NSMutableArray new];
|
|
NSMutableArray *pathArr = [NSMutableArray new];
|
|
|
- NASFileAudioDataModel *dataModel = _audioOutSidedataArray[_index];
|
|
|
|
|
|
|
+ NASFileAudioDataModel *dataModel = _allAudioDataArray[_index];
|
|
|
|
|
|
|
|
previewAudioPortraitDetailsView *topDetailsV = [[previewAudioPortraitDetailsView alloc] initWithFrame:CGRectZero withData:dataModel];
|
|
previewAudioPortraitDetailsView *topDetailsV = [[previewAudioPortraitDetailsView alloc] initWithFrame:CGRectZero withData:dataModel];
|
|
|
[self.view addSubview:topDetailsV];
|
|
[self.view addSubview:topDetailsV];
|
|
@@ -525,79 +527,92 @@
|
|
|
{
|
|
{
|
|
|
addAudioToPlayListViewController *vc = [addAudioToPlayListViewController new];
|
|
addAudioToPlayListViewController *vc = [addAudioToPlayListViewController new];
|
|
|
[self.navigationController pushViewController:vc animated:YES];
|
|
[self.navigationController pushViewController:vc animated:YES];
|
|
|
|
|
+
|
|
|
|
|
+ KWeakSelf
|
|
|
|
|
+ vc.didNeedToRegetAudioPlayListFun = ^{
|
|
|
|
|
+ [weakSelf.audioPlayListV reGetDataFun];
|
|
|
|
|
+ [weakSelf AddNewAudioToListFun];
|
|
|
|
|
+ };
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+#pragma mark 处理本地是否需要添加新加的的音乐
|
|
|
|
|
+- (void)AddNewAudioToListFun
|
|
|
|
|
+{
|
|
|
|
|
+ [[DFPlayer sharedPlayer] df_reloadData];
|
|
|
|
|
+
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
#pragma mark - DFPLayer dataSource
|
|
#pragma mark - DFPLayer dataSource
|
|
|
- (NSArray<DFPlayerModel *> *)df_audioDataForPlayer:(DFPlayer *)player{
|
|
- (NSArray<DFPlayerModel *> *)df_audioDataForPlayer:(DFPlayer *)player{
|
|
|
_dataArray = [NSMutableArray array];
|
|
_dataArray = [NSMutableArray array];
|
|
|
|
|
|
|
|
- for (int i = 0; i < _audioOutSidedataArray.count; i++) {
|
|
|
|
|
|
|
+ _allAudioDataArray = [NSMutableArray array];
|
|
|
|
|
+
|
|
|
|
|
+ //首次进来
|
|
|
|
|
+ if(_isfirstEnterType){
|
|
|
|
|
+ _isfirstEnterType = NO;
|
|
|
|
|
|
|
|
- NASFileAudioDataModel *yourModel = _audioOutSidedataArray[i];
|
|
|
|
|
|
|
+ //把外面传入的音频作为第一次传入
|
|
|
|
|
+ NASFileAudioDataModel *yourModel = _outSideDataModel;
|
|
|
DFPlayerModel *model = [[DFPlayerModel alloc] init];
|
|
DFPlayerModel *model = [[DFPlayerModel alloc] init];
|
|
|
- model.audioId = i;//****重要。AudioId从0开始,仅标识当前音频在数组中的位置。
|
|
|
|
|
|
|
+ model.audioId = 0;//****重要。AudioId从0开始,仅标识当前音频在数组中的位置。
|
|
|
|
|
|
|
|
NSString *filePath = yourModel.path;
|
|
NSString *filePath = yourModel.path;
|
|
|
NSString *urlStr = ksharedAppDelegate.NASFileByBoxService;
|
|
NSString *urlStr = ksharedAppDelegate.NASFileByBoxService;
|
|
|
|
|
|
|
|
NSString *string = filePath;
|
|
NSString *string = filePath;
|
|
|
NSString *filePathBase64 = [iTools base64UrlEncoder:string];
|
|
NSString *filePathBase64 = [iTools base64UrlEncoder:string];
|
|
|
- // NSData *data = [string dataUsingEncoding:NSUTF8StringEncoding];
|
|
|
|
|
- // NSString *filePathBase64 = [data base64EncodedStringWithOptions:NSDataBase64EncodingEndLineWithLineFeed];
|
|
|
|
|
-
|
|
|
|
|
- // NSData *data2 = [[NSData alloc] initWithBase64EncodedString:filePathBase64 options:NSDataBase64DecodingIgnoreUnknownCharacters];
|
|
|
|
|
- //
|
|
|
|
|
- // NSString *string32 =[[NSString alloc] initWithData:data2 encoding:NSUTF8StringEncoding];
|
|
|
|
|
- // HLog(@"hxd1111: %@",string32);
|
|
|
|
|
|
|
|
|
|
- //filePath = [filePath stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
|
|
|
|
|
- //NSString *fileUrl = [[NSString alloc] initWithFormat:@"%@getFile?path=%@",urlStr,filePath];
|
|
|
|
|
- //NSString *fileUrl = [[NSString alloc] initWithFormat:@"%@getFiles?path=%@",urlStr,filePath];
|
|
|
|
|
NSString *fileUrl = [[NSString alloc] initWithFormat:@"%@getFiles/%@",urlStr,filePathBase64];
|
|
NSString *fileUrl = [[NSString alloc] initWithFormat:@"%@getFiles/%@",urlStr,filePathBase64];
|
|
|
- HLog(@"hxd2222:%@",fileUrl);
|
|
|
|
|
- //fileUrl = @"http://transfertest.armclouding.com:10006/getFile?path=/storage/emulated/0/Download/录音大师-2024.05.22-16:57.mp3";
|
|
|
|
|
-
|
|
|
|
|
- //fileUrl = @"http://m10.music.126.net/20240527160012/d3f165dc686ac01afd4497400b2c2c58/ymusic/5353/0f0f/0358/d99739615f8e5153d77042092f07fd77.mp3";
|
|
|
|
|
- //fileUrl = @"https://www.cambridgeenglish.org/images/153149-movers-sample-listening-test-vol2.mp3";
|
|
|
|
|
- //fileUrl = @"https://www.cambridgeenglish.org/images/506891-a2-key-for-schools-listening-sample-test.mp3";
|
|
|
|
|
- //fileUrl = @"http://downsc.chinaz.net/Files/DownLoad/sound1/201906/11582.mp3";
|
|
|
|
|
- //fileUrl = @"http://downsc.chinaz.net/files/download/sound1/201206/1638.mp3";
|
|
|
|
|
- //fileUrl =@"http://192.168.11.248:9888/getFile?path=/storage/C47D-46D2/audioTest/jiajiaeeyinyue.mp3";
|
|
|
|
|
- //fileUrl =@"http://transfertest.armclouding.com:21025/getFiles/L3N0b3JhZ2UvZW11bGF0ZWQvMC9NdXNpYy9hYmMubXAz";
|
|
|
|
|
-
|
|
|
|
|
- //fileUrl = @"http://downsc.chinaz.net/files/download/sound1/201206/1638.mp3";
|
|
|
|
|
- //fileUrl = @"http://transfertest.armclouding.com:21025/test/abc/abc.mp3";
|
|
|
|
|
- //fileUrl = @"http://transfertest.armclouding.com:21025/test/abc/obj.mp3"; //0603 16:40验证可以播放
|
|
|
|
|
- //fileUrl = @"http://file.phone.androidscloud.com:8210/document/newFile/download/1/ikIm5C0KjKNvusTF6tIH/LowLevelMultipartUpload_44933618366140107699/1.mp3";
|
|
|
|
|
-
|
|
|
|
|
- // fileUrl = @"http://transfertest.armclouding.com:10001/getFile?path=/storage/6C07-E638/miniType/%E9%9F%B3%E9%A2%91%E6%A0%BC%E5%BC%8Fing/jiajiaeeyinyue.mp3";
|
|
|
|
|
-
|
|
|
|
|
- //fileUrl = @"http://transfertest.armclouding.com:21025/getFiles/L3N0b3JhZ2UvZW11bGF0ZWQvMC9NdXNpYy9vYmoubXAz";
|
|
|
|
|
- //fileUrl = @"http://transfertest.armclouding.com:21025/getFiles/L3NkY2FyZC9NdXNpYy9vYmoubXAz";
|
|
|
|
|
-
|
|
|
|
|
- //fileUrl = @"http://testprivacy.phone.armclouding.com:1801/h5/25883214_yinyue.wma";//不支持此媒体的格式
|
|
|
|
|
- //fileUrl = @"http://testprivacy.phone.armclouding.com:1801/h5/ffgfge.m4a";//可以播放
|
|
|
|
|
- //fileUrl = @"http://testprivacy.phone.armclouding.com:1801/h5/j14_yinyue.ogg";//不支持此媒体的格式
|
|
|
|
|
-
|
|
|
|
|
- // fileUrl = [fileUrl stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
|
|
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
NSURL * curURL = [NSURL fileURLWithPath:fileUrl];
|
|
NSURL * curURL = [NSURL fileURLWithPath:fileUrl];
|
|
|
- HLog(@"%@",curURL.absoluteString);
|
|
|
|
|
model.audioUrl = curURL;
|
|
model.audioUrl = curURL;
|
|
|
-
|
|
|
|
|
- // if ([yourModel.yourUrl hasPrefix:@"http"]) {//网络音频
|
|
|
|
|
- // model.audioUrl = [self getAvailableURL:yourModel.yourUrl];
|
|
|
|
|
- // }else{//本地音频
|
|
|
|
|
- // NSString *path = [[NSBundle mainBundle] pathForResource:yourModel.yourUrl ofType:@""];
|
|
|
|
|
- // if (path) {
|
|
|
|
|
- // model.audioUrl = [NSURL fileURLWithPath:path];
|
|
|
|
|
- // }
|
|
|
|
|
- // }
|
|
|
|
|
|
|
+ HLog(@"%@",curURL.absoluteString);
|
|
|
[_dataArray addObject:model];
|
|
[_dataArray addObject:model];
|
|
|
|
|
+
|
|
|
|
|
+ [_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;
|
|
|
|
|
+ NSString *urlStr = ksharedAppDelegate.NASFileByBoxService;
|
|
|
|
|
+
|
|
|
|
|
+ NSString *string = filePath;
|
|
|
|
|
+ NSString *filePathBase64 = [iTools base64UrlEncoder:string];
|
|
|
|
|
+
|
|
|
|
|
+ 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];
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
HLog(@"%@ --- %ld",_dataArray,_dataArray.count);
|
|
HLog(@"%@ --- %ld",_dataArray,_dataArray.count);
|
|
|
return [_dataArray copy];
|
|
return [_dataArray copy];
|
|
|
|
|
|
|
|
|
|
+ // if ([yourModel.yourUrl hasPrefix:@"http"]) {//网络音频
|
|
|
|
|
+ // model.audioUrl = [self getAvailableURL:yourModel.yourUrl];
|
|
|
|
|
+ // }else{//本地音频
|
|
|
|
|
+ // NSString *path = [[NSBundle mainBundle] pathForResource:yourModel.yourUrl ofType:@""];
|
|
|
|
|
+ // if (path) {
|
|
|
|
|
+ // model.audioUrl = [NSURL fileURLWithPath:path];
|
|
|
|
|
+ // }
|
|
|
|
|
+ // }
|
|
|
|
|
+
|
|
|
}
|
|
}
|
|
|
- (DFPlayerInfoModel *)df_audioInfoForPlayer:(DFPlayer *)player{
|
|
- (DFPlayerInfoModel *)df_audioInfoForPlayer:(DFPlayer *)player{
|
|
|
|
|
|
|
@@ -680,7 +695,6 @@
|
|
|
[self setTitleFunByIndex];
|
|
[self setTitleFunByIndex];
|
|
|
[[DFPlayer sharedPlayer] df_reloadData];//需在传入数据源后调用
|
|
[[DFPlayer sharedPlayer] df_reloadData];//需在传入数据源后调用
|
|
|
|
|
|
|
|
- [DFPlayer sharedPlayer].playMode = DFPlayerModeOrderCycle;
|
|
|
|
|
|
|
|
|
|
KWeakSelf
|
|
KWeakSelf
|
|
|
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
|
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
|
@@ -697,8 +711,8 @@
|
|
|
|
|
|
|
|
-(void)setTitleFunByIndex
|
|
-(void)setTitleFunByIndex
|
|
|
{
|
|
{
|
|
|
- if(_index < _audioOutSidedataArray.count){
|
|
|
|
|
- NASFileAudioDataModel* dataModel = _audioOutSidedataArray[_index];
|
|
|
|
|
|
|
+ if(_index < _allAudioDataArray.count){
|
|
|
|
|
+ NASFileAudioDataModel* dataModel = _allAudioDataArray[_index];
|
|
|
//self.titleLabel.text = dataModel.name;
|
|
//self.titleLabel.text = dataModel.name;
|
|
|
_AudioTitleLab.text = dataModel.name;
|
|
_AudioTitleLab.text = dataModel.name;
|
|
|
|
|
|
|
@@ -718,8 +732,8 @@
|
|
|
|
|
|
|
|
#pragma mark 音频可以播放
|
|
#pragma mark 音频可以播放
|
|
|
- (void)audioPlayerByIndex:(NSInteger)index{
|
|
- (void)audioPlayerByIndex:(NSInteger)index{
|
|
|
- if(index >=0 && index < _audioOutSidedataArray.count){
|
|
|
|
|
- NASFileAudioDataModel *dataModel = _audioOutSidedataArray[index];
|
|
|
|
|
|
|
+ if(index >=0 && index < _allAudioDataArray.count){
|
|
|
|
|
+ NASFileAudioDataModel *dataModel = _allAudioDataArray[index];
|
|
|
|
|
|
|
|
lastFileModel *lastFileMod = [lastFileModel new];
|
|
lastFileModel *lastFileMod = [lastFileModel new];
|
|
|
lastFileMod.path = dataModel.path;
|
|
lastFileMod.path = dataModel.path;
|