[vlc-commits] macosx: add NSString helper to show time in VLC ticks

Felix Paul Kühne git at videolan.org
Thu Jan 31 17:58:38 CET 2019


vlc | branch: master | Felix Paul Kühne <felix at feepk.net> | Thu Jan 31 17:16:58 2019 +0100| [586e3387bbdec27329d70ab53db667de7ce9a7b8] | committer: Felix Paul Kühne

macosx: add NSString helper to show time in VLC ticks

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=586e3387bbdec27329d70ab53db667de7ce9a7b8
---

 modules/gui/macosx/NSString+Helpers.h | 10 ++++++++++
 modules/gui/macosx/NSString+Helpers.m |  7 +++++++
 2 files changed, 17 insertions(+)

diff --git a/modules/gui/macosx/NSString+Helpers.h b/modules/gui/macosx/NSString+Helpers.h
index 7c2da8e7e1..7e61b6509b 100644
--- a/modules/gui/macosx/NSString+Helpers.h
+++ b/modules/gui/macosx/NSString+Helpers.h
@@ -85,6 +85,16 @@ NSImage *imageFromRes(NSString *name);
 + (instancetype)stringWithTime:(long long int)time;
 
 /**
+ Creates an NSString with the given time in VLC ticks
+
+ This method allocates and initializes an NSString with the given
+ time formatted as displayable time
+
+ \param time   Time in VLC ticks
+ */
++ (instancetype)stringWithTimeFromTicks:(vlc_tick_t)time;
+
+/**
  Creates an NSString from the given null-terminated C string
  buffer encoded as base64
 
diff --git a/modules/gui/macosx/NSString+Helpers.m b/modules/gui/macosx/NSString+Helpers.m
index 96c9272280..dcddce1036 100644
--- a/modules/gui/macosx/NSString+Helpers.m
+++ b/modules/gui/macosx/NSString+Helpers.m
@@ -69,6 +69,13 @@ NSString *const kVLCMediaUnknown = @"Unknown";
     }
 }
 
++ (instancetype)stringWithTimeFromTicks:(vlc_tick_t)time
+{
+    char psz_time[MSTRTIME_MAX_SIZE];
+    return [NSString stringWithUTF8String:
+            secstotimestr(psz_time, (int)SEC_FROM_VLC_TICK(time))];
+}
+
 + (instancetype)stringWithTime:(long long int)time
 {
     if (time > 0) {



More information about the vlc-commits mailing list