|
|
@@ -11,13 +11,21 @@
|
|
|
|
|
|
#import "NASFileAudioModel.h"
|
|
|
#import "lastFileManager.h"
|
|
|
+#import <QuartzCore/QuartzCore.h>
|
|
|
|
|
|
@interface audioPlayerViewController ()<DFPlayerDelegate,DFPlayerDataSource>
|
|
|
|
|
|
-@property (nonatomic, assign) BOOL isOlnyOneType;
|
|
|
+@property (nonatomic, strong) UIImageView*bgImageView;//中间图片
|
|
|
+@property (nonatomic, strong) UIImageView*playImageView;//
|
|
|
+@property (nonatomic, strong) CABasicAnimation *rotationAnimation;
|
|
|
|
|
|
-@property (nonatomic, strong) UIImageView*bgImageView;
|
|
|
@property (nonatomic, strong)UIButton * playPauseBtn;
|
|
|
+@property (nonatomic, strong)UIButton * playNextBtn;
|
|
|
+@property (nonatomic, strong)UIButton * playLastBtn;
|
|
|
+
|
|
|
+@property (nonatomic, strong)UIButton * playListBtn;//歌单
|
|
|
+@property (nonatomic, strong)UIButton * playModelBtn;//播放模式(单机 随机 循环)
|
|
|
+
|
|
|
@property (nonatomic, strong) NSMutableArray<DFPlayerModel *> *dataArray;
|
|
|
@property (nonatomic, assign) NSInteger lastAudioIndex;//-1未记录
|
|
|
@end
|
|
|
@@ -27,7 +35,6 @@
|
|
|
- (void)viewDidLoad {
|
|
|
[super viewDidLoad];
|
|
|
// Do any additional setup after loading the view.
|
|
|
- _isOlnyOneType = NO;
|
|
|
|
|
|
[self.toolBar setHidden:YES];
|
|
|
[self.navigationBar setHidden:YES];
|
|
|
@@ -46,13 +53,42 @@
|
|
|
[self.view addSubview:_bgImageView];
|
|
|
|
|
|
[_bgImageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
- make.top.equalTo(self.navBarBGView.mas_bottom).offset(105);
|
|
|
- make.width.mas_equalTo(256);
|
|
|
- make.height.mas_equalTo(256);
|
|
|
+ make.top.equalTo(self.navBarBGView.mas_bottom).offset(90);
|
|
|
+ make.width.mas_equalTo(200);
|
|
|
+ make.height.mas_equalTo(200);
|
|
|
make.centerX.mas_equalTo(0);
|
|
|
}];
|
|
|
|
|
|
|
|
|
+ _playImageView = [UIImageView new];
|
|
|
+ _playImageView.image = [UIImage imageNamed:@"audioPlayImg"];
|
|
|
+ [self.view addSubview:_playImageView];
|
|
|
+
|
|
|
+ [_playImageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
+ //make.top.equalTo(_bgImageView.mas_top).offset(-19);
|
|
|
+ make.top.equalTo(_bgImageView.mas_top).offset(-19 - 85);
|
|
|
+ make.width.mas_equalTo(110);
|
|
|
+ make.height.mas_equalTo(170);
|
|
|
+ //make.left.equalTo(_bgImageView.mas_right).offset(-60);
|
|
|
+ make.left.equalTo(_bgImageView.mas_right).offset(-60 +55);
|
|
|
+ }];
|
|
|
+
|
|
|
+ [self setAnchorPoint:CGPointMake(1.0, 0.0) forView:_playImageView];
|
|
|
+
|
|
|
+ //底部UI背景
|
|
|
+ UIImageView* bottombgImageView = [UIImageView new];
|
|
|
+ bottombgImageView.image = [UIImage imageNamed:@"audioBottomBg"];
|
|
|
+ bottombgImageView.userInteractionEnabled = YES;
|
|
|
+ [self.view addSubview:bottombgImageView];
|
|
|
+
|
|
|
+ CGFloat bottombgH = SCREEN_W*280.0/375.0;
|
|
|
+ [bottombgImageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
+ make.bottom.mas_equalTo(0);
|
|
|
+ make.left.mas_equalTo(0);
|
|
|
+ make.right.mas_equalTo(0);
|
|
|
+ make.height.mas_equalTo(bottombgH);
|
|
|
+ }];
|
|
|
+
|
|
|
[self initDFPlayer];
|
|
|
}
|
|
|
|
|
|
@@ -62,9 +98,9 @@
|
|
|
[[DFPlayer sharedPlayer] df_initPlayerWithUserId:nil];
|
|
|
[DFPlayer sharedPlayer].dataSource = self;
|
|
|
[DFPlayer sharedPlayer].delegate = self;
|
|
|
- [DFPlayer sharedPlayer].playMode = DFPlayerModeOnlyOnce;
|
|
|
+ [DFPlayer sharedPlayer].playMode = DFPlayerModeOrderCycle;
|
|
|
[DFPlayer sharedPlayer].isObserveWWAN = NO;
|
|
|
- // [[DFPlayer sharedPlayer] df_reloadData];//需在传入数据源后调用
|
|
|
+ // [[DFPlayer sharedPlayer] df_reloadData];//需在传入数据源后调用
|
|
|
|
|
|
|
|
|
UIImage *nextImage = [UIImage imageNamed:@"dfplayer_next"];
|
|
|
@@ -72,28 +108,96 @@
|
|
|
UIImage *playImage = [UIImage imageNamed:@"dfplayer_play"];
|
|
|
UIImage *pauseImage = [UIImage imageNamed:@"dfplayer_pause"];
|
|
|
|
|
|
-// UIImage *singleImage = [UIImage imageNamed:@"dfplayer_single"];
|
|
|
-// UIImage *circleImage = [UIImage imageNamed:@"dfplayer_circle"];
|
|
|
-
|
|
|
UIImage *ovalImage = [UIImage imageNamed:@"dfplayer_oval"];
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
+
|
|
|
DFPlayerUIManager *mgr = [DFPlayerUIManager sharedManager];
|
|
|
//缓冲条
|
|
|
-// [mgr df_bufferViewWithFrame:CGRectZero
|
|
|
-// trackTintColor:[[UIColor lightGrayColor] colorWithAlphaComponent:0.5]
|
|
|
-// progressTintColor:[UIColor colorWithWhite:1 alpha:0.5]
|
|
|
-// superView:self.view];
|
|
|
+ // [mgr df_bufferViewWithFrame:CGRectZero
|
|
|
+ // trackTintColor:[[UIColor lightGrayColor] colorWithAlphaComponent:0.5]
|
|
|
+ // progressTintColor:[UIColor colorWithWhite:1 alpha:0.5]
|
|
|
+ // superView:self.view];
|
|
|
+
|
|
|
+ //播放暂停按钮
|
|
|
+ //_playPauseBtn = [mgr df_playPauseBtnWithFrame:CGRectZero playImage:playImage pauseImage:pauseImage superView:self.view block:nil];
|
|
|
+
|
|
|
+ _playPauseBtn = [[UIButton alloc] init];
|
|
|
+ [_playPauseBtn setImage:playImage forState:UIControlStateSelected];
|
|
|
+ [_playPauseBtn setImage:pauseImage forState:UIControlStateNormal];
|
|
|
+ [_playPauseBtn addTarget:self action:@selector(playOrPauseButtonDidClickFun:) forControlEvents:UIControlEventTouchUpInside];
|
|
|
+ [self.view addSubview:_playPauseBtn];
|
|
|
+ _playPauseBtn.selected = YES;
|
|
|
+
|
|
|
+ [_playPauseBtn mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
+ make.bottom.mas_equalTo(-54);
|
|
|
+ make.height.mas_equalTo(32);
|
|
|
+ make.width.mas_equalTo(32);
|
|
|
+ make.centerX.mas_equalTo(0);
|
|
|
+ }];
|
|
|
+
|
|
|
+
|
|
|
+ //下一首按钮
|
|
|
+ _playNextBtn = [mgr df_nextBtnWithFrame:CGRectZero image:nextImage superView:self.view block:nil];
|
|
|
+ [_playNextBtn setImage:[UIImage imageNamed:@"dfplayer_next_none"] forState:UIControlStateDisabled];
|
|
|
+ [_playNextBtn mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
+ make.centerY.equalTo(_playPauseBtn.mas_centerY).offset(0);
|
|
|
+ make.height.mas_equalTo(32);
|
|
|
+ make.width.mas_equalTo(32);
|
|
|
+ make.left.equalTo(_playPauseBtn.mas_right).offset(50);
|
|
|
+ }];
|
|
|
+
|
|
|
+ //上一首按钮
|
|
|
+ _playLastBtn = [mgr df_lastBtnWithFrame:CGRectZero image:lastImage superView:self.view block:nil];
|
|
|
+ [_playLastBtn setImage:[UIImage imageNamed:@"dfplayer_last_none"] forState:UIControlStateDisabled];
|
|
|
+
|
|
|
+ [_playLastBtn mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
+ make.centerY.equalTo(_playPauseBtn.mas_centerY).offset(0);
|
|
|
+ make.height.mas_equalTo(32);
|
|
|
+ make.width.mas_equalTo(32);
|
|
|
+ make.right.equalTo(_playPauseBtn.mas_left).offset(-50);
|
|
|
+ }];
|
|
|
+
|
|
|
+ //歌单
|
|
|
+ _playListBtn = [[UIButton alloc] init];
|
|
|
+ [_playListBtn setImage:[UIImage imageNamed:@"dfplayer_playlist"] forState:UIControlStateNormal];
|
|
|
+ //[_playListBtn addTarget:self action:@selector(playOrPauseButtonDidClickFun:) forControlEvents:UIControlEventTouchUpInside];
|
|
|
+ [self.view addSubview:_playListBtn];
|
|
|
+
|
|
|
+ [_playListBtn mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
+ make.centerY.equalTo(_playPauseBtn.mas_centerY).offset(0);
|
|
|
+ make.height.mas_equalTo(25);
|
|
|
+ make.width.mas_equalTo(25);
|
|
|
+ //make.left.equalTo(_playNextBtn.mas_right).offset(50);
|
|
|
+ make.right.mas_equalTo(-20);
|
|
|
+ }];
|
|
|
+
|
|
|
+ // //播放模式按钮
|
|
|
+ // [mgr df_typeBtnWithFrame:typeRect singleImage:singleImage circleImage:circleImage shuffleImage:shuffleImage superView:_bgView block:nil];
|
|
|
+
|
|
|
+ //播放模型
|
|
|
+ _playModelBtn = [[UIButton alloc] init];
|
|
|
+ [_playModelBtn setImage:[UIImage imageNamed:@"dfplayer_circle"] forState:UIControlStateNormal];
|
|
|
+ [_playModelBtn addTarget:self action:@selector(didClickPlayModelButtonFun:) forControlEvents:UIControlEventTouchUpInside];
|
|
|
+ [self.view addSubview:_playModelBtn];
|
|
|
+
|
|
|
+ [_playModelBtn mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
+ make.centerY.equalTo(_playPauseBtn.mas_centerY).offset(0);
|
|
|
+ make.height.mas_equalTo(25);
|
|
|
+ make.width.mas_equalTo(25);
|
|
|
+ make.left.mas_equalTo(20);
|
|
|
+ }];
|
|
|
+
|
|
|
+
|
|
|
//进度条
|
|
|
UISlider * curSlider = [mgr df_sliderWithFrame:CGRectZero
|
|
|
- minimumTrackTintColor:[UIColor hwColor:@"#0CDEFD"]
|
|
|
- maximumTrackTintColor:[UIColor hwColor:@"#E3E3E3"]
|
|
|
- trackHeight:4
|
|
|
- thumbImage:[ovalImage imageByResizeToSize:(CGSize){15,14}]
|
|
|
- superView:self.view];
|
|
|
+ minimumTrackTintColor:[UIColor hwColor:@"#0CDEFD"]
|
|
|
+ maximumTrackTintColor:[UIColor hwColor:@"#E3E3E3"]
|
|
|
+ trackHeight:4
|
|
|
+ thumbImage:[ovalImage imageByResizeToSize:(CGSize){15,14}]
|
|
|
+ superView:self.view];
|
|
|
|
|
|
[curSlider mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
- make.top.equalTo(_bgImageView.mas_bottom).offset(100);
|
|
|
+ make.bottom.equalTo(_playPauseBtn.mas_top).offset(-40);
|
|
|
make.height.mas_equalTo(40);
|
|
|
make.left.mas_equalTo(70);
|
|
|
make.right.mas_equalTo(-70);
|
|
|
@@ -101,10 +205,10 @@
|
|
|
|
|
|
//当前时间
|
|
|
UILabel *currentTimeLabel =[mgr df_currentTimeLabelWithFrame:CGRectZero
|
|
|
- textColor:[UIColor hwColor:@"#999999"]
|
|
|
- textAlignment:(NSTextAlignmentCenter)
|
|
|
- font:[UIFont systemFontOfSize:14.0]
|
|
|
- superView:self.view];
|
|
|
+ textColor:[UIColor hwColor:@"#999999"]
|
|
|
+ textAlignment:(NSTextAlignmentCenter)
|
|
|
+ font:[UIFont systemFontOfSize:14.0]
|
|
|
+ superView:self.view];
|
|
|
|
|
|
[currentTimeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
make.top.equalTo(curSlider.mas_top).offset(0);
|
|
|
@@ -115,10 +219,10 @@
|
|
|
|
|
|
//总时间
|
|
|
UILabel *totalTimeLabel = [mgr df_totalTimeLabelWithFrame:CGRectZero
|
|
|
- textColor:[UIColor hwColor:@"#999999"]
|
|
|
- textAlignment:(NSTextAlignmentCenter)
|
|
|
- font:[UIFont systemFontOfSize:14.0]
|
|
|
- superView:self.view];
|
|
|
+ textColor:[UIColor hwColor:@"#999999"]
|
|
|
+ textAlignment:(NSTextAlignmentCenter)
|
|
|
+ font:[UIFont systemFontOfSize:14.0]
|
|
|
+ superView:self.view];
|
|
|
|
|
|
[totalTimeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
make.top.equalTo(curSlider.mas_top).offset(0);
|
|
|
@@ -127,44 +231,50 @@
|
|
|
make.left.equalTo(curSlider.mas_right).offset(5);
|
|
|
}];
|
|
|
|
|
|
-// //播放模式按钮
|
|
|
-// [mgr df_typeBtnWithFrame:typeRect singleImage:singleImage circleImage:circleImage shuffleImage:shuffleImage superView:_bgView block:nil];
|
|
|
-
|
|
|
- //播放暂停按钮
|
|
|
- _playPauseBtn = [mgr df_playPauseBtnWithFrame:CGRectZero playImage:playImage pauseImage:pauseImage superView:self.view block:nil];
|
|
|
-
|
|
|
- [_playPauseBtn mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
- make.top.equalTo(curSlider.mas_bottom).offset(20);
|
|
|
- make.height.mas_equalTo(30);
|
|
|
- make.width.mas_equalTo(30);
|
|
|
- make.centerX.mas_equalTo(0);
|
|
|
- }];
|
|
|
+}
|
|
|
|
|
|
+#pragma mark 开始和暂停 按钮点击时间
|
|
|
+- (void)playOrPauseButtonDidClickFun:(UIButton*)but
|
|
|
+{
|
|
|
+ but.selected = !but.selected;
|
|
|
|
|
|
- //下一首按钮
|
|
|
- UIButton * nextBtn = [mgr df_nextBtnWithFrame:CGRectZero image:nextImage superView:self.view block:nil];
|
|
|
- if(_isOlnyOneType){
|
|
|
- nextBtn.hidden = YES;
|
|
|
+ if(but.selected){
|
|
|
+ [self startRotatingImage];
|
|
|
+ [self startPlayingRotateRightImage];
|
|
|
+
|
|
|
+ [[DFPlayer sharedPlayer] df_play];
|
|
|
}
|
|
|
- [nextBtn mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
- make.top.equalTo(curSlider.mas_bottom).offset(20);
|
|
|
- make.height.mas_equalTo(30);
|
|
|
- make.width.mas_equalTo(30);
|
|
|
- make.left.equalTo(_playPauseBtn.mas_right).offset(50);
|
|
|
- }];
|
|
|
-
|
|
|
- //上一首按钮
|
|
|
- UIButton * lastBtn = [mgr df_lastBtnWithFrame:CGRectZero image:lastImage superView:self.view block:nil];
|
|
|
- if(_isOlnyOneType){
|
|
|
- lastBtn.hidden = YES;
|
|
|
+ else{
|
|
|
+ [self stopRotatingImage];
|
|
|
+ [self stopPlayingRotateRightImage];
|
|
|
+
|
|
|
+ [[DFPlayer sharedPlayer] df_pause];
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+#pragma mark 开始和暂停 按钮点击时间
|
|
|
+- (void)didClickPlayModelButtonFun:(UIButton*)but
|
|
|
+{
|
|
|
+ switch ([DFPlayer sharedPlayer].playMode) {
|
|
|
+ case DFPlayerModeSingleCycle://单曲循环->顺序循环
|
|
|
+ [DFPlayer sharedPlayer].playMode = DFPlayerModeOrderCycle;
|
|
|
+ [but setImage:[UIImage imageNamed:@"dfplayer_circle"] forState:UIControlStateNormal];
|
|
|
+ [[iToast makeText:NSLocalizedString(@"NAS_audio_playModel_circle",nil)] show];
|
|
|
+ break;
|
|
|
+ case DFPlayerModeOrderCycle://顺序循环->随机循环
|
|
|
+ [DFPlayer sharedPlayer].playMode = DFPlayerModeShuffleCycle;
|
|
|
+ [but setImage:[UIImage imageNamed:@"dfplayer_shuffle"] forState:UIControlStateNormal];
|
|
|
+ [[iToast makeText:NSLocalizedString(@"NAS_audio_playModel_shuffle",nil)] show];
|
|
|
+ break;
|
|
|
+ case DFPlayerModeShuffleCycle://随机循环->单曲循环
|
|
|
+ [DFPlayer sharedPlayer].playMode = DFPlayerModeSingleCycle;
|
|
|
+ [but setImage:[UIImage imageNamed:@"dfplayer_single"] forState:UIControlStateNormal];
|
|
|
+ [[iToast makeText:NSLocalizedString(@"NAS_audio_playModel_single",nil)] show];
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ break;
|
|
|
}
|
|
|
|
|
|
- [lastBtn mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
- make.top.equalTo(curSlider.mas_bottom).offset(20);
|
|
|
- make.height.mas_equalTo(30);
|
|
|
- make.width.mas_equalTo(30);
|
|
|
- make.right.equalTo(_playPauseBtn.mas_left).offset(-50);
|
|
|
- }];
|
|
|
}
|
|
|
|
|
|
#pragma mark - DFPLayer dataSource
|
|
|
@@ -173,31 +283,22 @@
|
|
|
|
|
|
for (int i = 0; i < _audioOutSidedataArray.count; i++) {
|
|
|
|
|
|
- if(_isOlnyOneType){
|
|
|
- if(i!=_index){
|
|
|
- continue;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
NASFileAudioDataModel *yourModel = _audioOutSidedataArray[i];
|
|
|
DFPlayerModel *model = [[DFPlayerModel alloc] init];
|
|
|
model.audioId = i;//****重要。AudioId从0开始,仅标识当前音频在数组中的位置。
|
|
|
- if(_isOlnyOneType){
|
|
|
- model.audioId = 0;
|
|
|
- }
|
|
|
+
|
|
|
NSString *filePath = yourModel.path;
|
|
|
NSString *urlStr = ksharedAppDelegate.NASFileByBoxService;
|
|
|
|
|
|
NSString *string = filePath;
|
|
|
NSString *filePathBase64 = [iTools base64UrlEncoder:string];
|
|
|
-// NSData *data = [string dataUsingEncoding:NSUTF8StringEncoding];
|
|
|
-// NSString *filePathBase64 = [data base64EncodedStringWithOptions:NSDataBase64EncodingEndLineWithLineFeed];
|
|
|
+ // 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);
|
|
|
+ // 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];
|
|
|
@@ -205,7 +306,7 @@
|
|
|
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";
|
|
|
@@ -219,7 +320,7 @@
|
|
|
//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: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";
|
|
|
@@ -228,33 +329,33 @@
|
|
|
//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];
|
|
|
+ // fileUrl = [fileUrl stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
|
|
|
|
|
|
NSURL * curURL = [NSURL fileURLWithPath:fileUrl];
|
|
|
HLog(@"%@",curURL.absoluteString);
|
|
|
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];
|
|
|
-// }
|
|
|
-// }
|
|
|
+ // 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];
|
|
|
+ // }
|
|
|
+ // }
|
|
|
[_dataArray addObject:model];
|
|
|
}
|
|
|
HLog(@"%@ --- %ld",_dataArray,_dataArray.count);
|
|
|
return [_dataArray copy];
|
|
|
-
|
|
|
+
|
|
|
}
|
|
|
- (DFPlayerInfoModel *)df_audioInfoForPlayer:(DFPlayer *)player{
|
|
|
|
|
|
DFPlayerInfoModel *infoModel = [[DFPlayerInfoModel alloc] init];
|
|
|
-// infoModel.audioName = @"";//yourModel.yourName;
|
|
|
-// infoModel.audioSinger = @"";//yourModel.yourSinger;
|
|
|
-// infoModel.audioAlbum = @"";//yourModel.yourAlbum;
|
|
|
-// infoModel.audioLyrics = @"";//[NSString stringWithContentsOfFile:lyricPath encoding:NSUTF8StringEncoding error:nil];
|
|
|
+ // infoModel.audioName = @"";//yourModel.yourName;
|
|
|
+ // infoModel.audioSinger = @"";//yourModel.yourSinger;
|
|
|
+ // infoModel.audioAlbum = @"";//yourModel.yourAlbum;
|
|
|
+ // infoModel.audioLyrics = @"";//[NSString stringWithContentsOfFile:lyricPath encoding:NSUTF8StringEncoding error:nil];
|
|
|
//infoModel.audioImage = [UIImage imageWithData:imageData];
|
|
|
return infoModel;
|
|
|
}
|
|
|
@@ -262,14 +363,14 @@
|
|
|
#pragma mark - DFPlayer delegate
|
|
|
//加入播放队列
|
|
|
- (void)df_playerAudioAddToPlayQueue:(DFPlayer *)player{
|
|
|
-// [self tableViewReloadData];
|
|
|
-// dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
|
|
|
-// dispatch_async(dispatch_get_main_queue(), ^{
|
|
|
-// self.navigationItem.title = player.currentAudioInfoModel.audioName;
|
|
|
-// self->_bgView.image = [self getBackgroundImage:player.currentAudioInfoModel.audioImage];
|
|
|
-// self->_noticeLabel.text = player.currentAudioInfoModel.audioLyrics ? @"" : @"无可用歌词";
|
|
|
-// });
|
|
|
-// });
|
|
|
+ // [self tableViewReloadData];
|
|
|
+ // dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
|
|
|
+ // dispatch_async(dispatch_get_main_queue(), ^{
|
|
|
+ // self.navigationItem.title = player.currentAudioInfoModel.audioName;
|
|
|
+ // self->_bgView.image = [self getBackgroundImage:player.currentAudioInfoModel.audioImage];
|
|
|
+ // self->_noticeLabel.text = player.currentAudioInfoModel.audioLyrics ? @"" : @"无可用歌词";
|
|
|
+ // });
|
|
|
+ // });
|
|
|
}
|
|
|
|
|
|
//缓冲进度代理
|
|
|
@@ -279,17 +380,22 @@
|
|
|
|
|
|
//播放进度代理
|
|
|
- (void)df_player:(DFPlayer *)player progress:(CGFloat)progress currentTime:(CGFloat)currentTime{
|
|
|
- HLog(@"音频播放进度:%@",player.currentAudioModel);
|
|
|
+ HLog(@"音频播放进度:%f --- %f",progress,currentTime);
|
|
|
|
|
|
if(_lastAudioIndex != player.currentAudioModel.audioId){
|
|
|
_lastAudioIndex = player.currentAudioModel.audioId;
|
|
|
_index = _lastAudioIndex;
|
|
|
[self setTitleFunByIndex];
|
|
|
[self audioPlayerByIndex:_lastAudioIndex];
|
|
|
+
|
|
|
+ [self startRotatingImage];
|
|
|
+ [self startPlayingRotateRightImage];
|
|
|
}
|
|
|
|
|
|
if(progress >= 1.0){
|
|
|
_lastAudioIndex = -1;
|
|
|
+
|
|
|
+ [self stopRotatingImage];
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -298,16 +404,16 @@
|
|
|
if (statusCode == DFPlayerStatusNoNetwork) {
|
|
|
//[self showAlert:@"没有网络连接"];
|
|
|
}else if(statusCode == DFPlayerStatusViaWWAN){
|
|
|
-// [self showAlert:@"继续播放将产生流量费用" okBlock:^{
|
|
|
-// [DFPlayer sharedPlayer].isObserveWWAN = NO;
|
|
|
-// [[DFPlayer sharedPlayer] df_playWithAudioId:player.currentAudioModel.audioId];
|
|
|
-// }];
|
|
|
+ // [self showAlert:@"继续播放将产生流量费用" okBlock:^{
|
|
|
+ // [DFPlayer sharedPlayer].isObserveWWAN = NO;
|
|
|
+ // [[DFPlayer sharedPlayer] df_playWithAudioId:player.currentAudioModel.audioId];
|
|
|
+ // }];
|
|
|
[DFPlayer sharedPlayer].isObserveWWAN = NO;
|
|
|
[[DFPlayer sharedPlayer] df_playWithAudioId:player.currentAudioModel.audioId];
|
|
|
}else if(statusCode == DFPlayerStatusTimeOut){
|
|
|
//[self showAlert:@"请求超时"];
|
|
|
}else if(statusCode == DFPlayerStatusCacheSucc){
|
|
|
-
|
|
|
+
|
|
|
[[DFPlayer sharedPlayer] df_playWithAudioId:player.currentAudioModel.audioId];
|
|
|
}else{
|
|
|
HLog(@"状态码:%lu",(unsigned long)statusCode);
|
|
|
@@ -350,34 +456,10 @@
|
|
|
|
|
|
- (void)playAudioFun
|
|
|
{
|
|
|
- if(_isOlnyOneType){
|
|
|
- if( self.dataArray.count == 1){
|
|
|
- DFPlayerModel *model = self.dataArray.firstObject;
|
|
|
-
|
|
|
- if(_audioOutSidedataArray.count > _index){
|
|
|
- NASFileAudioDataModel *yourModel = _audioOutSidedataArray[_index];
|
|
|
- NSString *name = yourModel.name;
|
|
|
- name = [name lowercaseString];
|
|
|
- if([name containsString:@".ogg"]
|
|
|
- ||[name containsString:@".wma"]){
|
|
|
- [[iToast makeText:NSLocalizedString(@"play_video_fail_tip",nil)] show];
|
|
|
- _playPauseBtn.userInteractionEnabled = NO;
|
|
|
- return;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- [[DFPlayer sharedPlayer] df_playWithAudioId:model.audioId];
|
|
|
- }
|
|
|
- }
|
|
|
- else{
|
|
|
- if(_index < self.dataArray.count){
|
|
|
- DFPlayerModel *model = self.dataArray[_index];
|
|
|
- [[DFPlayer sharedPlayer] df_playWithAudioId:model.audioId];
|
|
|
- }
|
|
|
+ if(_index < self.dataArray.count){
|
|
|
+ DFPlayerModel *model = self.dataArray[_index];
|
|
|
+ [[DFPlayer sharedPlayer] df_playWithAudioId:model.audioId];
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
|
|
|
#pragma mark 音频可以播放
|
|
|
@@ -395,7 +477,74 @@
|
|
|
lastFileMod.lastPreTime = [iTools getNowTimeStamp];
|
|
|
|
|
|
[[lastFileManager shareManager] saveFileInfoWith:lastFileMod with:dataModel.path];
|
|
|
-
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+#pragma mark 图片旋转相关
|
|
|
+- (void)startRotatingImage {
|
|
|
+ // 停止当前动画(如果有的话)
|
|
|
+ [self stopRotatingImage];
|
|
|
+
|
|
|
+ // 创建一个CABasicAnimation实例
|
|
|
+ self.rotationAnimation = [CABasicAnimation animationWithKeyPath:@"transform.rotation.z"];
|
|
|
+
|
|
|
+ // 设置动画的起始值(从0度开始)
|
|
|
+ self.rotationAnimation.fromValue = [NSNumber numberWithFloat:0];
|
|
|
+
|
|
|
+ // 设置动画的结束值(旋转360度,注意这里是弧度制)
|
|
|
+ self.rotationAnimation.toValue = [NSNumber numberWithFloat:M_PI * 2];
|
|
|
+
|
|
|
+ // 设置动画的持续时间
|
|
|
+ self.rotationAnimation.duration = 5.0; // 可以根据需要调整旋转速度
|
|
|
+
|
|
|
+ // 设置动画的重复次数,这里设置为HUGE_VALF表示无限次
|
|
|
+ self.rotationAnimation.repeatCount = HUGE_VALF;
|
|
|
+
|
|
|
+ // 将动画添加到imageView的layer上
|
|
|
+ [self.bgImageView.layer addAnimation:self.rotationAnimation forKey:@"rotateAnimation"];
|
|
|
+}
|
|
|
+
|
|
|
+- (void)stopRotatingImage {
|
|
|
+ // 移除imageView上的动画
|
|
|
+ [self.bgImageView.layer removeAnimationForKey:@"rotateAnimation"];
|
|
|
+
|
|
|
+ // 可选:如果你需要重置imageView的旋转状态(回到初始位置)
|
|
|
+ // 注意:这可能会使动画看起来不连续,因为你是直接设置了layer的transform
|
|
|
+ self.bgImageView.layer.transform = CATransform3DIdentity;
|
|
|
+}
|
|
|
+
|
|
|
+- (void)restartRotatingImage {
|
|
|
+ // 直接调用startRotatingImage来重新启动动画
|
|
|
+ [self startRotatingImage];
|
|
|
+}
|
|
|
+
|
|
|
+- (void)startPlayingRotateRightImage
|
|
|
+{
|
|
|
+
|
|
|
+ [UIView animateWithDuration:2 animations:^{
|
|
|
+ self.playImageView.transform = CGAffineTransformMakeRotation(0);
|
|
|
+ //self.playImageView.transform = CGAffineTransformRotate(self.playImageView.transform, -M_PI / 6); // 逆时针旋转30度
|
|
|
+ }];
|
|
|
+}
|
|
|
+
|
|
|
+- (void)stopPlayingRotateRightImage
|
|
|
+{
|
|
|
+ [UIView animateWithDuration:2 animations:^{
|
|
|
+ self.playImageView.transform = CGAffineTransformMakeRotation(-M_PI*0.15);
|
|
|
+ }];
|
|
|
+}
|
|
|
+
|
|
|
+//改变旋转中心???
|
|
|
+- (void)setAnchorPoint:(CGPoint)anchorPoint forView:(UIView *)view
|
|
|
+{
|
|
|
+ CGPoint oldOrigin = view.frame.origin;
|
|
|
+ view.layer.anchorPoint = anchorPoint;
|
|
|
+ CGPoint newOrigin = view.frame.origin;
|
|
|
+ CGPoint transition;
|
|
|
+ transition.x = newOrigin.x - oldOrigin.x;
|
|
|
+ transition.y = newOrigin.y - oldOrigin.y;
|
|
|
+ view.center = CGPointMake (view.center.x - transition.x, view.center.y - transition.y);
|
|
|
+}
|
|
|
+
|
|
|
@end
|