]> git.sesse.net Git - vlc/blobdiff - modules/gui/macosx/applescript.m
macosx: fix resume playback guards, do not resume for folder urls
[vlc] / modules / gui / macosx / applescript.m
index 947dbc8b7bade5939d5f0794b81568e9cfb9db64..2d9273be73cda86aa7929bf72ceb888326586e72 100644 (file)
@@ -29,6 +29,7 @@
 #import "applescript.h"
 #import "CoreInteraction.h"
 #import "playlist.h"
+#import <vlc_url.h>
 
 /*****************************************************************************
  * VLGetURLScriptCommand implementation
             if (o_url != nil)
                 [[NSDocumentController sharedDocumentController] noteNewRecentDocumentURL: o_url];
 
-            NSArray *o_result = [NSArray arrayWithObject:[NSDictionary dictionaryWithObject:o_urlString forKey: @"ITEM_URL"]];
+            input_thread_t * p_input = pl_CurrentInput(VLCIntf);
+            BOOL b_returned = NO;
+
+            if (p_input) {
+                b_returned = input_AddSubtitle(p_input, [o_urlString UTF8String], true);
+                vlc_object_release(p_input);
+                if (!b_returned)
+                    return nil;
+            }
+
+            NSDictionary *o_dic;
+            NSArray *o_array;
+            o_dic = [NSDictionary dictionaryWithObject:o_urlString forKey:@"ITEM_URL"];
+            o_array = [NSArray arrayWithObject: o_dic];
 
             if (b_autoplay)
-                [[[VLCMain sharedInstance] playlist] appendArray: o_result atPos: -1 enqueue: NO];
+                [[[VLCMain sharedInstance] playlist] appendArray: o_array atPos: -1 enqueue: NO];
             else
-                [[[VLCMain sharedInstance] playlist] appendArray: o_result atPos: -1 enqueue: YES];
+                [[[VLCMain sharedInstance] playlist] appendArray: o_array atPos: -1 enqueue: YES];
         }
     }
     return nil;
     [[VLCCoreInteraction sharedInstance] setVolume:(int)i_audioVolume];
 }
 
+- (int) audioDesync {
+    input_thread_t * p_input = pl_CurrentInput(VLCIntf);
+    int i_delay = -1;
+
+    if(!p_input)
+        return i_delay;
+
+    i_delay = var_GetTime(p_input, "audio-delay");
+    vlc_object_release(p_input);
+
+    return (i_delay / 1000);
+}
+
+- (void) setAudioDesync:(int)i_audioDesync {
+    input_thread_t * p_input = pl_CurrentInput(VLCIntf);
+    if(!p_input)
+        return;
+
+    var_SetTime(p_input, "audio-delay", i_audioDesync * 1000);
+    vlc_object_release(p_input);
+}
+
 - (int) currentTime {
     input_thread_t * p_input = pl_CurrentInput(VLCIntf);
     int64_t i_currentTime = -1;