vlc | branch: master | David Fuhrmann <[email protected]> | Sun Feb 24 17:09:26 2013 +0100| [021b9f2579d69f3ca2b7b8d809836785a3f15515] | committer: David Fuhrmann
macosx: show current pos and remaining or total time in fs controller > http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=021b9f2579d69f3ca2b7b8d809836785a3f15515 --- modules/gui/macosx/ControlsBar.h | 1 - modules/gui/macosx/ControlsBar.m | 5 --- modules/gui/macosx/MainWindow.m | 2 +- modules/gui/macosx/fspanel.h | 7 ++-- modules/gui/macosx/fspanel.m | 65 +++++++++++++++++++++++++++++++++----- 5 files changed, 62 insertions(+), 18 deletions(-) diff --git a/modules/gui/macosx/ControlsBar.h b/modules/gui/macosx/ControlsBar.h index 5b8310e..b2d1cb3 100644 --- a/modules/gui/macosx/ControlsBar.h +++ b/modules/gui/macosx/ControlsBar.h @@ -146,7 +146,6 @@ - (void)updateVolumeSlider; - (void)updateControls; -- (void)updatePosAndTimeInFSPanel:(VLCFSPanel *)o_fspanel; @end diff --git a/modules/gui/macosx/ControlsBar.m b/modules/gui/macosx/ControlsBar.m index 1ebcef1..411ba83 100644 --- a/modules/gui/macosx/ControlsBar.m +++ b/modules/gui/macosx/ControlsBar.m @@ -988,9 +988,4 @@ else \ [[VLCMainMenu sharedInstance] setRateControlsEnabled: b_control]; } -- (void)updatePosAndTimeInFSPanel:(VLCFSPanel *)o_fspanel -{ - [o_fspanel setStreamPos:[o_time_sld floatValue] andTime: [o_time_fld stringValue]]; -} - @end diff --git a/modules/gui/macosx/MainWindow.m b/modules/gui/macosx/MainWindow.m index 2318d12..c6c1d7b 100644 --- a/modules/gui/macosx/MainWindow.m +++ b/modules/gui/macosx/MainWindow.m @@ -608,7 +608,7 @@ static VLCMainWindow *_o_sharedInstance = nil; - (void)updateTimeSlider { [o_controls_bar updateTimeSlider]; - [[self controlsBar] updatePosAndTimeInFSPanel:o_fspanel]; + [o_fspanel updatePositionAndTime]; [[[VLCMain sharedInstance] voutController] updateWindowsControlsBarWithSelector:@selector(updateTimeSlider)]; } diff --git a/modules/gui/macosx/fspanel.h b/modules/gui/macosx/fspanel.h index 37c855a..56bd4b0 100644 --- a/modules/gui/macosx/fspanel.h +++ b/modules/gui/macosx/fspanel.h @@ -52,7 +52,7 @@ - (void)setPlay; - (void)setPause; - (void)setStreamTitle: (NSString *)o_title; -- (void)setStreamPos: (float)f_pos andTime: (NSString *)o_time; +- (void)updatePositionAndTime; - (void)setSeekable: (BOOL)b_seekable; - (void)setVolumeLevel: (int)i_volumeLevel; @@ -83,7 +83,8 @@ { NSColor *fillColor; NSButton *o_prev, *o_next, *o_bwd, *o_fwd, *o_play, *o_fullscreen; - NSTextField *o_streamTitle_txt, *o_streamPosition_txt; + NSTextField *o_streamTitle_txt; + VLCTimeField *o_streamPosition_txt, *o_streamLength_txt; NSSlider *o_fs_timeSlider, *o_fs_volumeSlider; VLCProgressView *o_progress_view; NSImage *o_background_img, *o_vol_sld_img, *o_vol_mute_img, *o_vol_max_img, *o_time_sld_img; @@ -96,7 +97,7 @@ - (void)setPlay; - (void)setPause; - (void)setStreamTitle: (NSString *)o_title; -- (void)setStreamPos: (float)f_pos andTime: (NSString *)o_time; +- (void)updatePositionAndTime; - (void)setSeekable: (BOOL)b_seekable; - (void)setVolumeLevel: (int)i_volumeLevel; - (IBAction)play:(id)sender; diff --git a/modules/gui/macosx/fspanel.m b/modules/gui/macosx/fspanel.m index 0de70bd..1849cbb 100644 --- a/modules/gui/macosx/fspanel.m +++ b/modules/gui/macosx/fspanel.m @@ -154,9 +154,9 @@ [[self contentView] setStreamTitle: o_title]; } -- (void)setStreamPos:(float) f_pos andTime:(NSString *)o_time +- (void)updatePositionAndTime { - [[self contentView] setStreamPos:f_pos andTime: o_time]; + [[self contentView] updatePositionAndTime]; } - (void)setSeekable:(BOOL) b_seekable @@ -458,15 +458,20 @@ /* time counter and stream title output fields */ s_rc = [self frame]; - s_rc.origin.x = 98; + // 10 px gap between time fields + s_rc.origin.x = 90; s_rc.origin.y = 64; - s_rc.size.width = 352; + s_rc.size.width = 361; s_rc.size.height = 14; addTextfield(NSTextField, o_streamTitle_txt, NSCenterTextAlignment, systemFontOfSize, whiteColor); + s_rc.origin.x = 15; + s_rc.origin.y = 64; + s_rc.size.width = 65; + addTextfield(VLCTimeField, o_streamPosition_txt, NSLeftTextAlignment, systemFontOfSize, whiteColor); s_rc.origin.x = 471; s_rc.origin.y = 64; s_rc.size.width = 65; - addTextfield(VLCTimeField, o_streamPosition_txt, NSRightTextAlignment, systemFontOfSize, whiteColor); + addTextfield(VLCTimeField, o_streamLength_txt, NSRightTextAlignment, systemFontOfSize, whiteColor); o_background_img = [[NSImage imageNamed:@"fs_background"] retain]; o_vol_sld_img = [[NSImage imageNamed:@"fs_volume_slider_bar"] retain]; @@ -514,10 +519,54 @@ [o_streamTitle_txt setStringValue: o_title]; } -- (void)setStreamPos:(float) f_pos andTime:(NSString *)o_time +- (void)updatePositionAndTime { - [o_streamPosition_txt setStringValue: o_time]; - [o_fs_timeSlider setFloatValue: f_pos]; + input_thread_t * p_input; + p_input = pl_CurrentInput(VLCIntf); + if (p_input) { + + vlc_value_t pos; + float f_updated; + + var_Get(p_input, "position", &pos); + f_updated = 10000. * pos.f_float; + [o_fs_timeSlider setFloatValue: f_updated]; + + vlc_value_t time; + char psz_time[MSTRTIME_MAX_SIZE]; + + var_Get(p_input, "time", &time); + mtime_t dur = input_item_GetDuration(input_GetItem(p_input)); + + // update total duration (right field) + if(dur <= 0) { + [o_streamLength_txt setHidden: YES]; + } else { + [o_streamLength_txt setHidden: NO]; + + NSString *o_total_time; + if ([o_streamLength_txt timeRemaining]) { + mtime_t remaining = 0; + if (dur > time.i_time) + remaining = dur - time.i_time; + o_total_time = [NSString stringWithFormat: @"-%s", secstotimestr(psz_time, (remaining / 1000000))]; + } else + o_total_time = [NSString stringWithUTF8String: secstotimestr(psz_time, (dur / 1000000))]; + + [o_streamLength_txt setStringValue: o_total_time]; + } + + // update current position (left field) + NSString *o_playback_pos = [NSString stringWithUTF8String: secstotimestr(psz_time, (time.i_time / 1000000))]; + + [o_streamPosition_txt setStringValue: o_playback_pos]; + vlc_object_release(p_input); + } else { + [o_fs_timeSlider setFloatValue: 0.0]; + [o_streamPosition_txt setStringValue: @"00:00"]; + [o_streamLength_txt setHidden: YES]; + } + } - (void)setSeekable:(BOOL)b_seekable _______________________________________________ vlc-commits mailing list [email protected] http://mailman.videolan.org/listinfo/vlc-commits
