]> git.sesse.net Git - vlc/blobdiff - modules/gui/macosx/applescript.m
macosx: do not allow playlist item deletion for sd modules
[vlc] / modules / gui / macosx / applescript.m
index fd67c3aea24b4b6cdd12286026cca7d765350e67..2d9273be73cda86aa7929bf72ceb888326586e72 100644 (file)
@@ -1,7 +1,7 @@
 /*****************************************************************************
  * applescript.m: MacOS X AppleScript support
  *****************************************************************************
- * Copyright (C) 2002-2012 VLC authors and VideoLAN
+ * Copyright (C) 2002-2013 VLC authors and VideoLAN
  * $Id$
  *
  * Authors: Derk-Jan Hartman <thedj@users.sourceforge.net>
 /*****************************************************************************
  * Preamble
  *****************************************************************************/
-#include "intf.h"
-#include "applescript.h"
-#include "CoreInteraction.h"
-#include "vlc_aout_intf.h"
+#import "intf.h"
+#import "applescript.h"
+#import "CoreInteraction.h"
+#import "playlist.h"
+#import <vlc_url.h>
 
 /*****************************************************************************
  * VLGetURLScriptCommand implementation
     NSString *o_urlString = [self directParameter];
 
     if ([o_command isEqualToString:@"GetURL"] || [o_command isEqualToString:@"OpenURL"]) {
-        intf_thread_t * p_intf = VLCIntf;
-        playlist_t * p_playlist = pl_Get(p_intf);
-
         if (o_urlString) {
-            NSURL * o_url;
-            input_item_t *p_input;
-            int returnValue;
+            BOOL b_autoplay = config_GetInt(VLCIntf, "macosx-autoplay");
+            NSURL * o_url = [NSURL fileURLWithPath: o_urlString];
+            if (o_url != nil)
+                [[NSDocumentController sharedDocumentController] noteNewRecentDocumentURL: o_url];
 
-            p_input = input_item_New([o_urlString fileSystemRepresentation],
-                                    [[[NSFileManager defaultManager]
-                                    displayNameAtPath: o_urlString] UTF8String]);
-            if (!p_input)
-                return nil;
+            input_thread_t * p_input = pl_CurrentInput(VLCIntf);
+            BOOL b_returned = NO;
 
-            returnValue = playlist_AddInput(p_playlist, p_input, PLAYLIST_INSERT,
-                               PLAYLIST_END, true, pl_Unlocked);
-            vlc_gc_decref(p_input);
+            if (p_input) {
+                b_returned = input_AddSubtitle(p_input, [o_urlString UTF8String], true);
+                vlc_object_release(p_input);
+                if (!b_returned)
+                    return nil;
+            }
 
-            if (returnValue != VLC_SUCCESS)
-                return nil;
+            NSDictionary *o_dic;
+            NSArray *o_array;
+            o_dic = [NSDictionary dictionaryWithObject:o_urlString forKey:@"ITEM_URL"];
+            o_array = [NSArray arrayWithObject: o_dic];
 
-            o_url = [NSURL fileURLWithPath: o_urlString];
-            if (o_url != nil)
-                [[NSDocumentController sharedDocumentController] noteNewRecentDocumentURL: o_url];
+            if (b_autoplay)
+                [[[VLCMain sharedInstance] playlist] appendArray: o_array atPos: -1 enqueue: NO];
+            else
+                [[[VLCMain sharedInstance] playlist] appendArray: o_array atPos: -1 enqueue: YES];
         }
     }
     return nil;
@@ -89,7 +91,7 @@
     playlist_t * p_playlist = pl_Get(p_intf);
 
     if ([o_command isEqualToString:@"play"])
-        [[VLCCoreInteraction sharedInstance] play];
+        [[VLCCoreInteraction sharedInstance] playOrPause];
     else if ([o_command isEqualToString:@"stop"])
         [[VLCCoreInteraction sharedInstance] stop];
     else if ([o_command isEqualToString:@"previous"])
     else if ([o_command isEqualToString:@"fullscreen"])
         [[VLCCoreInteraction sharedInstance] toggleFullscreen];
     else if ([o_command isEqualToString:@"mute"])
-        [[VLCCoreInteraction sharedInstance] setMute: YES];
+        [[VLCCoreInteraction sharedInstance] toggleMute];
     else if ([o_command isEqualToString:@"volumeUp"])
         [[VLCCoreInteraction sharedInstance] volumeUp];
     else if ([o_command isEqualToString:@"volumeDown"])
     [[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;