소스 검색

VLCKit: Reset time, remaining time and position of VLCMediaPlayer when media is changed

When the VLCMediaPlayer switches between two media, there is a short period of time when the new media is set but when the time, remaining time and position are still set to the last time and position of the previous media. This is visible on tvOS where there is a short time when switching media where the new title is already being displayed but the old time and position is still being shown. This commit resets the time, remaining time and position of the VLCMediaPlayer when its media has changed.

Signed-off-by: Felix Paul Kühne <fkuehne@videolan.org>
Benjamin Adolphi 9 년 전
부모
커밋
cc1ddef474
1개의 변경된 파일12개의 추가작업 그리고 1개의 파일을 삭제
  1. 12 1
      Sources/VLCMediaPlayer.m

+ 12 - 1
Sources/VLCMediaPlayer.m

@@ -1385,9 +1385,20 @@ static void HandleMediaPlayerSnapshot(const libvlc_event_t * event, void * self)
 - (void)mediaPlayerMediaChanged:(VLCMedia *)newMedia
 {
     [self willChangeValueForKey:@"media"];
-    if (_media != newMedia)
+    if (_media != newMedia) {
         _media = newMedia;
 
+        [self willChangeValueForKey:@"time"];
+        [self willChangeValueForKey:@"remainingTime"];
+        [self willChangeValueForKey:@"position"];
+        _cachedTime = [VLCTime nullTime];
+        _cachedRemainingTime = [VLCTime nullTime];
+        _position = 0.0f;
+        [self didChangeValueForKey:@"position"];
+        [self didChangeValueForKey:@"remainingTime"];
+        [self didChangeValueForKey:@"time"];
+    }
+
     [self didChangeValueForKey:@"media"];
 }