Browse Source

版本升级维护

yyqxiaoyin 5 years atrás
parent
commit
5c5322efb5

+ 16 - 0
MKRRadioManager/Classes/MKRRadioManager/MKRAVPlayer/MKRAVPlayer.h

@@ -49,10 +49,26 @@ typedef enum : NSUInteger {
 
 /**
  资源已经准备好播放
+ 如果 shouldAutoPlay = YES 播放器将在这个时机调用 -(void)play 方法
  */
 - (void)didReadyToPlay;
 
 /**
+ 播放完成
+ 
+ @param currentIndex 播放完成的资源在播放列表中的下表
+ */
+- (void)didFinishPlay:(NSInteger)currentIndex;
+
+/**
+ 收到系统发出的AVPlayerItemFailedToPlayToEndTimeErrorKey 通知
+ 播放失败 导致不能播到结束时间
+ 一般是因网络状况差 在进入中断后 即调用 -(void)playbackStalled 方法之后的一段时间内会调用此方法
+ 可以在此方法做重新播放操作
+ */
+- (void)didFailedToPlayToEndTime;
+
+/**
  播放中断
  */
 - (void)playbackStalled;

+ 22 - 6
MKRRadioManager/Classes/MKRRadioManager/MKRAVPlayer/MKRAVPlayer.m

@@ -137,7 +137,7 @@ NSURL * MKRUrlWithString(NSString *string){
     }
 }
 
-- (void)next{
+- (void)nextWhenPlayDidEnd{
     if (!self.playList.count) return;
     [self resetPlayer];
     switch (_playMode) {
@@ -151,16 +151,25 @@ NSURL * MKRUrlWithString(NSString *string){
             break;
         case MKRAVPlayerPlayModeOrder:
         default:{
-            NSInteger index = self.currentIndex + 1;
-            if (index > self.playList.count - 1) {
-                index = 0;
-            }
-            [self playAtIndex:index];
+            [self next];
         }
             break;
     }
 }
 
+- (void)next{
+    if (_playMode == MKRAVPlayerPlayModeRandom) {
+        [self nextWhenPlayDidEnd];
+        return;
+    }
+    [self resetPlayer];
+    NSInteger index = self.currentIndex + 1;
+    if (index > self.playList.count - 1) {
+        index = 0;
+    }
+    [self playAtIndex:index];
+}
+
 - (void)previous{
     if (!self.playList.count) return;
     [self resetPlayer];
@@ -309,6 +318,9 @@ NSURL * MKRUrlWithString(NSString *string){
 
 - (void)playerItemFailedToPlayToEndTime:(NSNotification *)note{
     NSLog(@"失败e没结束");
+    if (self.delegate && [self.delegate respondsToSelector:@selector(didFailedToPlayToEndTime)]) {
+        [self.delegate didFailedToPlayToEndTime];
+    }
 }
 
 - (void)failedToPlayToEndTimeError:(NSNotification *)note{
@@ -321,6 +333,10 @@ NSURL * MKRUrlWithString(NSString *string){
     self.seekTime = 0.0f;
     self.isSeeking = NO;
     [self next];
+    [self nextWhenPlayDidEnd];
+    if (self.delegate && [self.delegate respondsToSelector:@selector(didFinishPlay:)]) {
+        [self.delegate didFinishPlay:self.currentIndex];
+    }
 }
 
 #pragma mark - setter

+ 10 - 10
fastlane/report.xml

@@ -5,52 +5,52 @@
     
     
       
-      <testcase classname="fastlane.lanes" name="0: cocoapods" time="13.826914">
+      <testcase classname="fastlane.lanes" name="0: cocoapods" time="3.10735">
         
       </testcase>
     
       
-      <testcase classname="fastlane.lanes" name="1: git_add" time="0.044961">
+      <testcase classname="fastlane.lanes" name="1: git_add" time="0.026298">
         
       </testcase>
     
       
-      <testcase classname="fastlane.lanes" name="2: git_commit" time="0.05191">
+      <testcase classname="fastlane.lanes" name="2: git_commit" time="0.05097">
         
       </testcase>
     
       
-      <testcase classname="fastlane.lanes" name="3: push_to_git_remote" time="1.232763">
+      <testcase classname="fastlane.lanes" name="3: push_to_git_remote" time="1.257565">
         
       </testcase>
     
       
-      <testcase classname="fastlane.lanes" name="4: git_tag_exists" time="0.009783">
+      <testcase classname="fastlane.lanes" name="4: git_tag_exists" time="0.009335">
         
       </testcase>
     
       
-      <testcase classname="fastlane.lanes" name="5: remove_tag" time="0.817975">
+      <testcase classname="fastlane.lanes" name="5: remove_tag" time="0.828708">
         
       </testcase>
     
       
-      <testcase classname="fastlane.lanes" name="6: add_git_tag" time="0.016928">
+      <testcase classname="fastlane.lanes" name="6: add_git_tag" time="0.015299">
         
       </testcase>
     
       
-      <testcase classname="fastlane.lanes" name="7: push_git_tags" time="0.81416">
+      <testcase classname="fastlane.lanes" name="7: push_git_tags" time="0.911261">
         
       </testcase>
     
       
-      <testcase classname="fastlane.lanes" name="8: pod_lib_lint" time="10.567891">
+      <testcase classname="fastlane.lanes" name="8: pod_lib_lint" time="10.264703">
         
       </testcase>
     
       
-      <testcase classname="fastlane.lanes" name="9: pod_push" time="9.289852">
+      <testcase classname="fastlane.lanes" name="9: pod_push" time="9.122544">
         
       </testcase>