浏览代码

1.播放一首歌曲(不支持格式)时,播放列表添加歌曲后,当前正在播放歌曲名字和状态切换另一首

huangxiaodong 10 月之前
父节点
当前提交
8f90a078f3

+ 61 - 40
创维盒子/双子星云手机/Class/Set/previewFile/audioPlayerViewController.m

@@ -44,6 +44,7 @@
 @property (nonatomic, assign) NSInteger lastAudioIndex;//-1未记录
 
 @property (nonatomic, strong) audioPlayListView *audioPlayListV;
+@property (nonatomic, assign) BOOL isAddListType;//添加歌曲
 @end
 
 @implementation audioPlayerViewController
@@ -98,8 +99,11 @@
         
         _allAudioDataArray = [audioPlayListManager shareManager].audioPlayListArr;
         _lastAudioIndex = -1;
-        _index = [DFPlayer sharedPlayer].currentAudioModel.audioId;
-        [self setTitleFunByIndex];
+        if(!_isAddListType){//添加歌曲进来 不用改
+            _index = [DFPlayer sharedPlayer].currentAudioModel.audioId;
+            [self setTitleFunByIndex];
+        }
+        _isAddListType = YES;
         [self handleSomeUIFun];
     }
     
@@ -682,10 +686,13 @@
 #pragma mark 处理本地是否需要添加新加的的音乐
 - (void)AddNewAudioToListFun
 {
+    _isAddListType = YES;
+    
     [[DFPlayer sharedPlayer] df_reloadData];
     
     KWeakSelf
     dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
+        weakSelf.audioPlayListV.playingIndex = weakSelf.index;
         [weakSelf.audioPlayListV reGetDataFun];
     });
 }
@@ -831,7 +838,16 @@
 #pragma mark - DFPlayer delegate
 //加入播放队列
 - (void)df_playerAudioAddToPlayQueue:(DFPlayer *)player{
-    
+    _playPauseBtn.selected = YES;
+    NSInteger curPlayingindex = player.currentAudioModel.audioId;
+    if(curPlayingindex >= 0)
+    {
+        _lastAudioIndex = curPlayingindex;
+        _index = curPlayingindex;
+        [self setTitleFunByIndex];
+        [self startRotatingImage];
+        [self startPlayingRotateRightImage];
+    }
 }
 
 //缓冲进度代理
@@ -851,44 +867,49 @@
 //播放进度代理
 - (void)df_player:(DFPlayer *)player progress:(CGFloat)progress currentTime:(CGFloat)currentTime{
    
-    NSInteger index = player.currentAudioModel.audioId;
-    if(index >0 && index<_dataArray.count){
-        lastFileModel *lastFileMod = _allAudioDataArray[index];
-        //HLog(@"音频播放进度:%f --- %f --- %@ ---inddex:%ld ---- %ld",progress,currentTime,lastFileMod.name,_lastAudioIndex,index);
-    }
-    else{
-        //HLog(@"音频播放进度:%f --- %f",progress,currentTime);
-    }
-    
-    
-    playDelayed ++;
-    if(!_playPauseBtn.selected && playDelayed >= 3){
-        _playPauseBtn.selected = YES;
-    }
-    
-    //HLog(@"df_player progress hxd  _ind:%ld ---- %ld",_lastAudioIndex,player.currentAudioModel.audioId);
-    if(_lastAudioIndex != player.currentAudioModel.audioId)
-    {
-        _lastAudioIndex = player.currentAudioModel.audioId;
-        _index = _lastAudioIndex;
-//       HLog(@"df_player progress hxd  _ind:setTitleFunByIndex");
+//    NSInteger index = player.currentAudioModel.audioId;
+//    if(index >0 && index<_dataArray.count){
+//        lastFileModel *lastFileMod = _allAudioDataArray[index];
+//        //HLog(@"音频播放进度:%f --- %f --- %@ ---inddex:%ld ---- %ld",progress,currentTime,lastFileMod.name,_lastAudioIndex,index);
+//    }
+//    else{
+//        //HLog(@"音频播放进度:%f --- %f",progress,currentTime);
+//    }
+//    
+//    
+//    playDelayed ++;
+//    if(!_playPauseBtn.selected && playDelayed >= 3){
+//        _playPauseBtn.selected = YES;
+//    }
+//    
+//    NSInteger curPlayingindex = player.currentAudioModel.audioId;
+//    //HLog(@"df_player progress hxd  _ind:%ld ---- %ld",_lastAudioIndex,player.currentAudioModel.audioId);
+//    if(_lastAudioIndex != curPlayingindex
+//       && curPlayingindex >= 0 )
+//    {
+//        _lastAudioIndex = curPlayingindex;
+//        _index = curPlayingindex;
+////       HLog(@"df_player progress hxd  _ind:setTitleFunByIndex");
+////        [self setTitleFunByIndex];
+//        //[self audioPlayerByIndex:_lastAudioIndex];
+//        
+//        [self startRotatingImage];
+//        [self startPlayingRotateRightImage];
+//    }
+//    
+//    //尝试强行修改 歌曲名 后续有时间优化
+//    if(curPlayingindex >= 0){
+//        _lastAudioIndex = curPlayingindex;
+//        _index = curPlayingindex;
+//        //HLog(@"df_player progress hxd  _ind:setTitleFunByIndex");
 //        [self setTitleFunByIndex];
-        //[self audioPlayerByIndex:_lastAudioIndex];
-        
-        [self startRotatingImage];
-        [self startPlayingRotateRightImage];
-    }
-    
-    //尝试强行修改 歌曲名 后续有时间优化
-    _lastAudioIndex = player.currentAudioModel.audioId;
-    _index = _lastAudioIndex;
-    //HLog(@"df_player progress hxd  _ind:setTitleFunByIndex");
-    [self setTitleFunByIndex];
-    
-    if(progress >= 1.0){
-        _lastAudioIndex = -1;
-        [self stopRotatingImage];
-    }
+//    }
+//    
+ 
+//    if(progress >= 1.0){
+//        _lastAudioIndex = -1;
+//        [self stopRotatingImage];
+//    }
 }
 
 //状态信息代理

+ 1 - 1
创维盒子/双子星云手机/NAS/NASViewController.m

@@ -970,7 +970,7 @@
     haveNewVersionView.versionModel = versionModel;
     haveNewVersionView.isContinueCheckAlert = NO; // 是否继续走下一步弹窗检测流程
     [haveNewVersionView setBackgroundColor:RGBACOLOR(0, 0, 0, 0.5)];
-    [[iTools getKeyWindow] addSubview:haveNewVersionView];
+    [ksharedAppDelegate.window addSubview:haveNewVersionView];
     haveNewVersionView.isShow = YES;
     
     if(!versionModel.necessary){

+ 4 - 1
创维盒子/双子星云手机/Vendor/DFPlayer/DFPlayer.m

@@ -339,7 +339,9 @@ NSString * const DFPlaybackLikelyToKeepUpKey    = @"playbackLikelyToKeepUp";
     }
 
     if (self.delegate && [self.delegate respondsToSelector:@selector(df_playerAudioAddToPlayQueue:)]) {
-        [self.delegate df_playerAudioAddToPlayQueue:self];
+        mainBlock(^{
+            [self.delegate df_playerAudioAddToPlayQueue:self];
+        });
     }
 
     //hxd add 20240716 判断下载完成了没有 完成了 就修改 audioUrl
@@ -698,6 +700,7 @@ NSString * const DFPlaybackLikelyToKeepUpKey    = @"playbackLikelyToKeepUp";
         self.player = nil;
     }
     
+    [DFPlayer sharedPlayer].currentAudioModel = nil;
     [[DFPlayerUIManager sharedManager] dfUI_deallocPlayer];
 }