[vlc-commits] macosx/wizard: allow partial extract values to be entered in a sane manner (close #4991)

Felix Paul Kühne git at videolan.org
Fri Sep 7 16:19:47 CEST 2012


vlc/vlc-2.0 | branch: master | Felix Paul Kühne <fkuehne at videolan.org> | Fri Sep  7 16:13:32 2012 +0200| [31f1c24b125a19b096119fc843660dee3ffd0650] | committer: Felix Paul Kühne

macosx/wizard: allow partial extract values to be entered in a sane manner (close #4991)
(cherry picked from commit 38faa0be67f7df1fa4eca218aa63782e66d7806c)

> http://git.videolan.org/gitweb.cgi/vlc/vlc-2.0.git/?a=commit;h=31f1c24b125a19b096119fc843660dee3ffd0650
---

 modules/gui/macosx/wizard.m |   41 ++++++++++++++++++++++++++++-------------
 1 file changed, 28 insertions(+), 13 deletions(-)

diff --git a/modules/gui/macosx/wizard.m b/modules/gui/macosx/wizard.m
index f141539..d2006eb 100644
--- a/modules/gui/macosx/wizard.m
+++ b/modules/gui/macosx/wizard.m
@@ -1259,21 +1259,36 @@ static VLCWizard *_o_sharedInstance = nil;
             input_item_AddOption( p_input, [[o_t8_fld_mrl stringValue] UTF8String], VLC_INPUT_OPTION_TRUSTED );
 
             if(! [[o_userSelections objectForKey:@"partExtractFrom"]
-                isEqualToString:@""] )
-            {
-                input_item_AddOption( p_input, [[NSString
-                    stringWithFormat: @"start-time=%@", [o_userSelections
-                    objectForKey: @"partExtractFrom"]] UTF8String],
-                    VLC_INPUT_OPTION_TRUSTED );
+                isEqualToString:@""]) {
+                NSArray * components = [[o_userSelections objectForKey: @"partExtractFrom"] componentsSeparatedByString:@":"];
+                NSUInteger componentCount = [components count];
+                NSUInteger time = 0;
+                if (componentCount == 1)
+                    time = 1000000 * ([[components objectAtIndex:0] intValue]);
+                else if (componentCount == 2)
+                    time = 1000000 * ([[components objectAtIndex:0] intValue] * 60 + [[components objectAtIndex:1] intValue]);
+                else if (componentCount == 3)
+                    time = 1000000 * ([[components objectAtIndex:0] intValue] * 3600 + [[components objectAtIndex:1] intValue] * 60 + [[components objectAtIndex:2] intValue]);
+                else
+                    msg_Err(VLCIntf, "Invalid string format for time");
+                input_item_AddOption(p_input, [[NSString stringWithFormat: @"start-time=%lu", time] UTF8String], VLC_INPUT_OPTION_TRUSTED);
             }
 
             if(! [[o_userSelections objectForKey:@"partExtractTo"]
-                isEqualToString:@""] )
-            {
-                input_item_AddOption( p_input, [[NSString
-                    stringWithFormat: @"stop-time=%@", [o_userSelections
-                    objectForKey: @"partExtractTo"]] UTF8String],
-                    VLC_INPUT_OPTION_TRUSTED );
+                isEqualToString:@""]) {
+                NSArray * components = [[o_userSelections
+                    objectForKey: @"partExtractTo"] componentsSeparatedByString:@":"];
+                NSUInteger componentCount = [components count];
+                NSUInteger time = 0;
+                if (componentCount == 1)
+                    time = 1000000 * ([[components objectAtIndex:0] intValue]);
+                else if (componentCount == 2)
+                    time = 1000000 * ([[components objectAtIndex:0] intValue] * 60 + [[components objectAtIndex:1] intValue]);
+                else if (componentCount == 3)
+                    time = 1000000 * ([[components objectAtIndex:0] intValue] * 3600 + [[components objectAtIndex:1] intValue] * 60 + [[components objectAtIndex:2] intValue]);
+                else
+                    msg_Err(VLCIntf, "Invalid string format for time");
+                input_item_AddOption(p_input, [[NSString stringWithFormat: @"stop-time=%lu", time] UTF8String], VLC_INPUT_OPTION_TRUSTED);
             }
 
             input_item_AddOption( p_input, [[NSString stringWithFormat:
@@ -1357,7 +1372,7 @@ static VLCWizard *_o_sharedInstance = nil;
     if ([[o_userSelections objectForKey:@"partExtract"] isEqualToString: @"YES"])
     {
         [o_t8_fld_partExtract setStringValue: [NSString stringWithFormat:
-            _NS("yes: from %@ to %@ secs"),
+            _NS("yes: from %@ to %@"),
             [o_userSelections objectForKey:@"partExtractFrom"],
             [o_userSelections objectForKey:@"partExtractTo"]]];
     } else {



More information about the vlc-commits mailing list