浏览代码

版本升级维护

yyqxiaoyin 5 年之前
父节点
当前提交
d58ceb4a96

+ 2 - 2
Example/Podfile.lock

@@ -1,5 +1,5 @@
 PODS:
-  - MKRRadioManager (0.0.1)
+  - MKRRadioManager (0.0.2)
   - YYCategory (0.0.1)
 
 DEPENDENCIES:
@@ -15,7 +15,7 @@ EXTERNAL SOURCES:
     :path: "../"
 
 SPEC CHECKSUMS:
-  MKRRadioManager: dc051d4b5361a49c481dc08d28eaf07fa1c1084c
+  MKRRadioManager: 11a29ba22ec11c476bfadcc85770af93d0937792
   YYCategory: d85135b05d2806c90930a5bbadfc1501396a3db9
 
 PODFILE CHECKSUM: f65396e8a7f07654404054ab9d38dc4b7b6f8818

+ 2 - 2
Example/Pods/Local Podspecs/MKRRadioManager.podspec.json

@@ -1,6 +1,6 @@
 {
   "name": "MKRRadioManager",
-  "version": "0.0.1",
+  "version": "0.0.2",
   "summary": "A short description of MKRRadioManager.",
   "description": "TODO: Add long description of the pod here.",
   "homepage": "http://60.205.190.38:9000/iOS/MKRRadioManager.git",
@@ -13,7 +13,7 @@
   },
   "source": {
     "git": "http://60.205.190.38:9000/iOS/MKRRadioManager.git",
-    "tag": "0.0.1"
+    "tag": "0.0.2"
   },
   "platforms": {
     "ios": "8.0"

+ 2 - 2
Example/Pods/Manifest.lock

@@ -1,5 +1,5 @@
 PODS:
-  - MKRRadioManager (0.0.1)
+  - MKRRadioManager (0.0.2)
   - YYCategory (0.0.1)
 
 DEPENDENCIES:
@@ -15,7 +15,7 @@ EXTERNAL SOURCES:
     :path: "../"
 
 SPEC CHECKSUMS:
-  MKRRadioManager: dc051d4b5361a49c481dc08d28eaf07fa1c1084c
+  MKRRadioManager: 11a29ba22ec11c476bfadcc85770af93d0937792
   YYCategory: d85135b05d2806c90930a5bbadfc1501396a3db9
 
 PODFILE CHECKSUM: f65396e8a7f07654404054ab9d38dc4b7b6f8818

+ 1 - 1
MKRRadioManager.podspec

@@ -8,7 +8,7 @@
 
 Pod::Spec.new do |s|
   s.name             = 'MKRRadioManager'
-  s.version          = '0.0.1'
+  s.version          = '0.0.2'
   s.summary          = 'A short description of MKRRadioManager.'
 
 # This description is used to generate tags and improve search results.

+ 11 - 1
MKRRadioManager/Classes/MKRRadioManager/MKRAVPlayer/MKRAVPlayer.h

@@ -109,7 +109,15 @@ typedef enum : NSUInteger {
 
 - (id)initWithObjectsPlayList:(NSArray<id<MKRRadioResorce>> *)playList playMode:(MKRAVPlayerPlayMode)playMode;
 
-- (void)updatePlayList:(NSArray<NSString *> *)playList;
+/**
+更新播放列表
+*/
+- (void)updateResourcePlayList:(NSArray<id<MKRRadioResorce>> *)playList;
+
+/**
+重新播放当前资源
+*/
+- (void)replayCurrentResource;
 
 @property(nonatomic, weak) id<MKRAVPlayerDelegate> delegate;
 
@@ -124,6 +132,8 @@ typedef enum : NSUInteger {
  */
 @property (nonatomic, assign) NSInteger currentIndex;
 
+@property (nonatomic, assign) id <MKRRadioResorce> currentResource;
+
 /**
  是否正在播放中
  */

+ 40 - 7
MKRRadioManager/Classes/MKRRadioManager/MKRAVPlayer/MKRAVPlayer.m

@@ -34,6 +34,8 @@ static void * PlayerStatusObservationContext = &PlayerStatusObservationContext;
 @property (nonatomic, copy)   MKRAVPlayerURLRequsetBlcok block;
 @property (nonatomic, assign) BOOL isSeeking;//是否快进或快退
 @property (nonatomic, assign) NSTimeInterval seekTime;//快进或者快退的目标时间
+@property (nonatomic, strong) NSMutableArray *resourcePlayList;//MKRRadioResorce播放列表
+@property (nonatomic, assign) BOOL initByUrlPlayList;//是字符串播放列表
 @end
 
 @implementation MKRAVPlayer
@@ -69,6 +71,7 @@ NSURL * MKRUrlWithString(NSString *string){
 - (id)initWithPlayList:(NSArray<NSString *> *)playList{
     self = [self init];
     if (self) {
+        self.initByUrlPlayList = YES;
         self.playList = playList;
     }
     return self;
@@ -85,6 +88,7 @@ NSURL * MKRUrlWithString(NSString *string){
 - (id)initWithContentURL:(NSURL *)aUrl{
     self = [self init];
     if (self) {
+        self.initByUrlPlayList = YES;
         self.playUrl  = aUrl;
         self.playList = [NSArray arrayWithObject:aUrl];
     }
@@ -97,21 +101,43 @@ NSURL * MKRUrlWithString(NSString *string){
 }
 
 - (id)initWithObjectsPlayList:(NSArray<id<MKRRadioResorce>> *)playList{
-    NSArray *urls = [playList valueForKey:@"songUrl"];
+    NSMutableArray *urls = [NSMutableArray arrayWithArray:[playList valueForKey:@"songUrl"]];
+    for (NSInteger i = 0; i<urls.count; i++) {
+        if ([urls[i] isEqual:[NSNull null]]) {
+            [urls replaceObjectAtIndex:i withObject:@""];
+        }
+    }
+    self.resourcePlayList = [NSMutableArray arrayWithArray:playList];
     return [self initWithPlayList:urls];
 }
 
 - (id)initWithObjectsPlayList:(NSArray<id<MKRRadioResorce>> *)playList playMode:(MKRAVPlayerPlayMode)playMode{
-    NSArray *urls = [playList valueForKey:@"songUrl"];
+    NSMutableArray *urls = [NSMutableArray arrayWithArray:[playList valueForKey:@"songUrl"]];
+    for (NSInteger i = 0; i<urls.count; i++) {
+        if ([urls[i] isEqual:[NSNull null]]) {
+            [urls replaceObjectAtIndex:i withObject:@""];
+        }
+    }
+    self.resourcePlayList = [NSMutableArray arrayWithArray:playList];
     return [self initWithPlayList:urls playMode:playMode];
 }
 
-- (void)updatePlayList:(NSArray<NSString *> *)playList{
-    self.playList = playList;
-    NSUInteger index = [playList indexOfObject:self.playUrl.absoluteString];
-    if (index != NSNotFound) {
-        self.currentIndex = index;
+- (void)updateResourcePlayList:(NSArray<id<MKRRadioResorce>> *)playList{
+    __block NSInteger index = 0;
+    [playList enumerateObjectsUsingBlock:^(id<MKRRadioResorce> obj, NSUInteger idx, BOOL * _Nonnull stop) {
+        if (obj.songID == self.currentResource.songID) {
+            index = idx;
+            *stop = YES;
+        }
+    }];
+    NSMutableArray *urls = [NSMutableArray arrayWithArray:[playList valueForKey:@"songUrl"]];
+    for (NSInteger i = 0; i<urls.count; i++) {
+        if ([urls[i] isEqual:[NSNull null]]) {
+            [urls replaceObjectAtIndex:i withObject:@""];
+        }
     }
+    self.currentIndex = index;
+    self.playList = urls;
 }
 
 #pragma mark - 播放相关
@@ -143,6 +169,7 @@ NSURL * MKRUrlWithString(NSString *string){
         self.currentIndex = index;
         NSString *url = [self.playList objectAtIndex:index];
         self.playUrl = MKRUrlWithString(url);
+        self.currentResource = self.resourcePlayList[index];
         [self play];
     }
 }
@@ -228,6 +255,11 @@ NSURL * MKRUrlWithString(NSString *string){
     }
 }
 
+- (void)replayCurrentResource{
+    [self resetPlayer];
+    [self playAtIndex:self.currentIndex];
+}
+
 - (void)resetPlayer{
     self.totalTime = 0;
     self.currentTime = 0;
@@ -394,6 +426,7 @@ NSURL * MKRUrlWithString(NSString *string){
         }
         [self resetPlayer];
         self.currentIndex = nextIndex;
+        self.currentResource = self.resourcePlayList[nextIndex];
         self.currentStatus = nil;
         NSString *url = [self.playList objectAtIndex:self.currentIndex];
         self.playUrl = MKRUrlWithString(url);

+ 1 - 1
upgrade.sh

@@ -1 +1 @@
-fastlane ManagerLib tag:0.0.1 target:MKRRadioManager
+fastlane ManagerLib tag:0.0.2 target:MKRRadioManager