Jelajahi Sumber

版本升级维护

yyqxiaoyin 5 tahun lalu
induk
melakukan
642c203c0f

+ 18 - 4
MKRRadioManager/Classes/MKRRadioManager/MKRAVPlayer/MKRAVPlayer.m

@@ -229,6 +229,8 @@ NSURL * MKRUrlWithString(NSString *string){
 }
 
 - (void)resetPlayer{
+    self.totalTime = 0;
+    self.currentTime = 0;
     self.playerItem = nil;
     self.isInitPlayer = NO;
     [self.player replaceCurrentItemWithPlayerItem:nil];
@@ -375,16 +377,28 @@ NSURL * MKRUrlWithString(NSString *string){
     self.seekTime = 0.0f;
     self.isSeeking = NO;
     BOOL shouldAutoNext = YES;
+    NSInteger nextIndex = 0;
     if (self.delegate && [self.delegate respondsToSelector:@selector(didFinishPlayWillAutoNext:)]) {
-        NSInteger nextIndex = [self _caculateNextIndex:self.currentIndex];
+        nextIndex = [self _caculateNextIndex:self.currentIndex];
         shouldAutoNext = [self.delegate didFinishPlayWillAutoNext:nextIndex];
     }
-    if (shouldAutoNext) {
-        [self nextWhenPlayDidEnd];
-    }
     if (self.delegate && [self.delegate respondsToSelector:@selector(didFinishPlay:)]) {
         [self.delegate didFinishPlay:self.currentIndex];
     }
+    if (shouldAutoNext) {
+        [self nextWhenPlayDidEnd];
+    }else{
+        if (self.playList.count <= nextIndex) {
+            return;
+        }
+        [self resetPlayer];
+        self.currentTime = 0;
+        self.totalTime = 0;
+        self.currentIndex = nextIndex;
+        self.currentStatus = nil;
+        NSString *url = [self.playList objectAtIndex:self.currentIndex];
+        self.playUrl = MKRUrlWithString(url);
+    }
 }
 
 #pragma mark - setter