*/
- (VLCTime *)time;
+@property (readonly) VLCTime *remainingTime;
+
- (void)setChapter:(int)value;
- (int)chapter;
- (int)countOfChapters;
/* Properties */
@property (readonly) NSNumber * numberValue;
@property (readonly) NSString * stringValue;
+@property (readonly) NSString * verboseStringValue;
@property (readonly) int intValue;
/* Comparitors */
return cachedTime;
}
+- (VLCTime *)remainingTime
+{
+ double currentTime = [[cachedTime numberValue] doubleValue];
+ double remaining = currentTime / position * (1 - position);
+ return [VLCTime timeWithNumber:[NSNumber numberWithDouble:-remaining]];
+}
+
- (void)setChapter:(int)value;
{
libvlc_media_player_set_chapter( instance, value, NULL );
- (void)mediaPlayerTimeChanged:(NSNumber *)newTime
{
[self willChangeValueForKey:@"time"];
+ [self willChangeValueForKey:@"remainingTime"];
[cachedTime release];
cachedTime = [[VLCTime timeWithNumber:newTime] retain];
+ [self didChangeValueForKey:@"remainingTime"];
[self didChangeValueForKey:@"time"];
}
}
}
+- (NSString *)verboseStringValue
+{
+ if (value)
+ {
+ long long duration = [value longLongValue] / 1000000;
+ long long positiveDuration = llabs(duration);
+ long hours = positiveDuration / 3600;
+ long mins = (positiveDuration / 60) % 60;
+ long seconds = positiveDuration % 60;
+ const char * remaining = duration < 0 ? " remaining" : "";
+ if (hours > 0)
+ return [NSString stringWithFormat:@"%d hours %d minutes%s", hours, mins, remaining];
+ else if (mins > 5)
+ return [NSString stringWithFormat:@"%d minutes%s", mins, remaining];
+ else
+ return [NSString stringWithFormat:@"%d seconds%s", seconds, remaining];
+ }
+ else
+ {
+ // Return a string that represents an undefined time.
+ return @"";
+ }
+}
+
- (int)intValue
{
if( value )