Commit 712fbbcd authored by Felix Paul Kühne's avatar Felix Paul Kühne

Fix remaining time display for live streams

parent a8db76ae
...@@ -1295,7 +1295,7 @@ static void HandleMediaPlayerSnapshot(const libvlc_event_t * event, void * self) ...@@ -1295,7 +1295,7 @@ static void HandleMediaPlayerSnapshot(const libvlc_event_t * event, void * self)
[self willChangeValueForKey:@"remainingTime"]; [self willChangeValueForKey:@"remainingTime"];
_cachedTime = [VLCTime timeWithNumber:newTime]; _cachedTime = [VLCTime timeWithNumber:newTime];
double currentTime = [[_cachedTime numberValue] doubleValue]; double currentTime = [[_cachedTime numberValue] doubleValue];
if (currentTime > 0) { if (currentTime > 0 && _position > 0.) {
double remaining = currentTime / _position * (1 - _position); double remaining = currentTime / _position * (1 - _position);
_cachedRemainingTime = [VLCTime timeWithNumber:@(-remaining)]; _cachedRemainingTime = [VLCTime timeWithNumber:@(-remaining)];
} else } else
......
...@@ -79,7 +79,12 @@ ...@@ -79,7 +79,12 @@
- (NSString *)stringValue - (NSString *)stringValue
{ {
if (_value) { if (_value) {
long long duration = [_value longLongValue] / 1000; long long duration = [_value longLongValue];
if (duration == INT_MAX || duration == INT_MIN) {
// Return a string that represents an undefined time.
return @"--:--";
}
duration = duration / 1000;
long long positiveDuration = llabs(duration); long long positiveDuration = llabs(duration);
if (positiveDuration > 3600) if (positiveDuration > 3600)
return [NSString stringWithFormat:@"%s%01ld:%02ld:%02ld", return [NSString stringWithFormat:@"%s%01ld:%02ld:%02ld",
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment