Commit 3e5fe8b6 authored by Pierre d'Herbemont's avatar Pierre d'Herbemont

macosx/framework: Export -[VLCMediaPlayer remainingTime] and -[VLCTime verboseStringValue].

parent 6aca0a67
......@@ -153,6 +153,8 @@ extern NSString * VLCMediaPlayerStateToString(VLCMediaPlayerState state);
*/
- (VLCTime *)time;
@property (readonly) VLCTime *remainingTime;
- (void)setChapter:(int)value;
- (int)chapter;
- (int)countOfChapters;
......
......@@ -44,6 +44,7 @@
/* Properties */
@property (readonly) NSNumber * numberValue;
@property (readonly) NSString * stringValue;
@property (readonly) NSString * verboseStringValue;
@property (readonly) int intValue;
/* Comparitors */
......
......@@ -384,6 +384,13 @@ static void HandleMediaInstanceStateChanged(const libvlc_event_t * event, void *
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 );
......@@ -726,9 +733,11 @@ static const VLCMediaPlayerState libvlc_to_local_state[] =
- (void)mediaPlayerTimeChanged:(NSNumber *)newTime
{
[self willChangeValueForKey:@"time"];
[self willChangeValueForKey:@"remainingTime"];
[cachedTime release];
cachedTime = [[VLCTime timeWithNumber:newTime] retain];
[self didChangeValueForKey:@"remainingTime"];
[self didChangeValueForKey:@"time"];
}
......
......@@ -117,6 +117,30 @@
}
}
- (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 )
......
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