]> git.sesse.net Git - vlc/commitdiff
macosx: show current pos and remaining or total time in fs controller
authorDavid Fuhrmann <david.fuhrmann@googlemail.com>
Sun, 24 Feb 2013 16:09:26 +0000 (17:09 +0100)
committerDavid Fuhrmann <david.fuhrmann@googlemail.com>
Sun, 24 Feb 2013 16:09:26 +0000 (17:09 +0100)
modules/gui/macosx/ControlsBar.h
modules/gui/macosx/ControlsBar.m
modules/gui/macosx/MainWindow.m
modules/gui/macosx/fspanel.h
modules/gui/macosx/fspanel.m

index 5b8310ed1a455818e405397804a0cc9ae1f45578..b2d1cb349bcd8cf070d954ddc5cd7c174b9bc4de 100644 (file)
 
 - (void)updateVolumeSlider;
 - (void)updateControls;
-- (void)updatePosAndTimeInFSPanel:(VLCFSPanel *)o_fspanel;
 
 @end
 
index 1ebcef105dd460146ccf680abaf7cdf73c9f9796..411ba8359f6aa374b46f3fe19c68891b4b8cf713 100644 (file)
@@ -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
index 2318d1204d2569e30de71c620d5d1d049d895b9c..c6c1d7be14cbce42382121726fb9e53ad77caac2 100644 (file)
@@ -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)];
 }
index 37c855a540b8854e927656b2613f1705a511cda8..56bd4b05a6ae00d62bdb12f94850b280c083e49c 100644 (file)
@@ -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;
index 0de70bd01db8b4a953e1544b53da6d16b206079d..1849cbb950b4e33638dd2bf991e7bc4c8493cdee 100644 (file)
     [[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
 
     /* 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];
     [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