Procházet zdrojové kódy

浮窗正在播放的歌曲,没有同步显示在最近文件中

huangxiaodong před 10 měsíci
rodič
revize
82203f6012

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

@@ -800,6 +800,8 @@
         [self handleSomeUIFun];
     });
     
+    [DFPlayer sharedPlayer].allAudioDataArray = [_allAudioDataArray mutableCopy];
+
     return [_dataArray copy];
     
     //本地音频
@@ -865,7 +867,7 @@
         _index = _lastAudioIndex;
 //       HLog(@"df_player progress hxd  _ind:setTitleFunByIndex");
 //        [self setTitleFunByIndex];
-        [self audioPlayerByIndex:_lastAudioIndex];
+        //[self audioPlayerByIndex:_lastAudioIndex];
         
         [self startRotatingImage];
         [self startPlayingRotateRightImage];
@@ -949,28 +951,6 @@
     }
 }
 
-#pragma mark 音频可以播放
-- (void)audioPlayerByIndex:(NSInteger)index{
-    if(index >=0 &&  index < _allAudioDataArray.count){
-        NASFileAudioDataModel *dataModel = _allAudioDataArray[index];
-        
-        lastFileModel *lastFileMod = [lastFileModel new];
-        lastFileMod.path = dataModel.path;
-        lastFileMod.name = dataModel.name;
-        lastFileMod.time = dataModel.time;
-        lastFileMod.size = dataModel.size;
-        lastFileMod.duration = dataModel.duration;
-        lastFileMod.type = @"audio";
-        lastFileMod.lastPreTime = [iTools getNowTimeStamp];
-        
-        //本地缓存
-        lastFileMod.localPath = [[audioPlayListManager shareManager] getAudioCacheFullPathBy:dataModel.name];
-        
-        [[lastFileManager shareManager] saveFileInfoWith:lastFileMod with:dataModel.path];
-        [[audioPlayListManager shareManager] saveFileInfoWith:lastFileMod with:dataModel.path];
-        
-    }
-}
 
 #pragma mark 图片旋转相关
 - (void)startRotatingImage {

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

@@ -13,6 +13,7 @@
 #import <AVFoundation/AVFoundation.h>
 #import "DFPlayerModel.h"
 #import "DFPlayerUIManager.h"
+#import "NASFileAudioModel.h"
 
 //播放器状态
 typedef NS_ENUM(NSInteger, DFPlayerState) {
@@ -302,6 +303,9 @@ typedef NS_ENUM(NSUInteger, DFPlayerStatusCode) {
  */
 @property (nonatomic, readonly, assign) CGFloat totalTime;
 
+@property (nonatomic, strong) NSMutableArray * allAudioDataArray;//所有的 播放数据(lastFileModel)
+
+
 #pragma mark - 缓存相关
 /**
  audioUrl对应的音频在本地的缓存地址

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

@@ -453,6 +453,10 @@ NSString * const DFPlaybackLikelyToKeepUpKey    = @"playbackLikelyToKeepUp";
     [self df_play];
     [self addProgressObserver];
     [self addPlayingCenterInfo];
+    
+    NSInteger index = self.currentAudioModel.audioId;
+    //HLog(@"audioId:%ld",self.currentAudioModel.audioId);
+    [self audioPlayerByIndex:index];
 }
 
 - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context{
@@ -959,7 +963,28 @@ NSString * const DFPlaybackLikelyToKeepUpKey    = @"playbackLikelyToKeepUp";
     }
 }
 
-
+#pragma mark 音频可以播放 保存最近文件和歌曲缓存
+- (void)audioPlayerByIndex:(NSInteger)index{
+    if(index >=0 &&  index < _allAudioDataArray.count){
+        NASFileAudioDataModel *dataModel = _allAudioDataArray[index];
+        
+        lastFileModel *lastFileMod = [lastFileModel new];
+        lastFileMod.path = dataModel.path;
+        lastFileMod.name = dataModel.name;
+        lastFileMod.time = dataModel.time;
+        lastFileMod.size = dataModel.size;
+        lastFileMod.duration = dataModel.duration;
+        lastFileMod.type = @"audio";
+        lastFileMod.lastPreTime = [iTools getNowTimeStamp];
+        
+        //本地缓存
+        lastFileMod.localPath = [[audioPlayListManager shareManager] getAudioCacheFullPathBy:dataModel.name];
+        
+        [[lastFileManager shareManager] saveFileInfoWith:lastFileMod with:dataModel.path];
+        [[audioPlayListManager shareManager] saveFileInfoWith:lastFileMod with:dataModel.path];
+        
+    }
+}
 
 @end