Parcourir la source

版本升级维护

yyqxiaoyin il y a 5 ans
Parent
commit
554b07b72d

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

@@ -231,8 +231,9 @@ NSURL * MKRUrlWithString(NSString *string){
     if (self.delegate && [self.delegate respondsToSelector:@selector(songPlayUrlWithIndex:completion:)]) {
         __weak __typeof(self)weakSelf = self;
         [self.delegate songPlayUrlWithIndex:self.currentIndex completion:^(NSString * _Nonnull resourceUrl) {
-            weakSelf.playUrl = MKRUrlWithString(resourceUrl);
-            [weakSelf createPlayerAndReadyToPlay];
+            __strong __typeof(weakSelf)strongSelf = weakSelf;
+            strongSelf.playUrl = MKRUrlWithString(resourceUrl);
+            [strongSelf createPlayerAndReadyToPlay];
         }];
         return;
     }
@@ -240,7 +241,9 @@ NSURL * MKRUrlWithString(NSString *string){
 }
 
 - (void)createPlayerAndReadyToPlay{
-    self.isInitPlayer = YES;
+    if (self.isInitPlayer) {
+        return;
+    }
     //注册通知
     [self registerNotification];
     if (self.playerItem) {
@@ -263,6 +266,7 @@ NSURL * MKRUrlWithString(NSString *string){
             }
         }];
     }
+    self.isInitPlayer = YES;
     if (@available(iOS 10.0, *)) {
         self.player.automaticallyWaitsToMinimizeStalling = NO;
     }