[vlc-devel] [PATCH] VLCKit: Reset time, remaining time and position of VLCMediaPlayer when media is changed
Benjamin Adolphi
b.adolphi at gmail.com
Wed Mar 2 22:34:24 CET 2016
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.
---
Sources/VLCMediaPlayer.m | 13 ++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)
diff --git a/Sources/VLCMediaPlayer.m b/Sources/VLCMediaPlayer.m
index 3395fa4..b04d99a 100644
--- a/Sources/VLCMediaPlayer.m
+++ b/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"];
}
--
2.7.2
More information about the vlc-devel
mailing list