]> git.sesse.net Git - vlc/commitdiff
macosx: re-write and simplify the apple event handlers for GetURL and OpenURL, make...
authorFelix Paul Kühne <fkuehne@videolan.org>
Sat, 9 Mar 2013 16:13:48 +0000 (17:13 +0100)
committerFelix Paul Kühne <fkuehne@videolan.org>
Sat, 9 Mar 2013 16:21:43 +0000 (17:21 +0100)
NEWS
modules/gui/macosx/applescript.m

diff --git a/NEWS b/NEWS
index 70b7e78665a96968a5557c09fc9604e92d16bfab..ef2f432c8f0643cb32581dda2ce61344c1e3f116 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -131,6 +131,8 @@ OS X Interface:
  * add support for playing video and showing audio visualizations side by side
  * improve fullscreen controller time slider with larger click target
  * rewrite of minimal macosx module for use within VLCKit
+ * add support for 'macosx-autoplay' to the Apple Event / Apple Script bindings
+   when adding new inputs
  * The Streaming/Transcoding wizard and the open dialog's output panel are
    deprecated now
 
index d9082caad49a86062580421ae9b027a27399b61e..bff1f311d39f74f20e60bcce75c1b236d7d1de31 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"
+#import "intf.h"
+#import "applescript.h"
+#import "CoreInteraction.h"
+#import "playlist.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;
-
-            p_input = input_item_New([o_urlString fileSystemRepresentation],
-                                    [[[NSFileManager defaultManager]
-                                    displayNameAtPath: o_urlString] UTF8String]);
-            if (!p_input)
-                return nil;
-
-            returnValue = playlist_AddInput(p_playlist, p_input, PLAYLIST_INSERT,
-                               PLAYLIST_END, true, pl_Unlocked);
-            vlc_gc_decref(p_input);
-
-            if (returnValue != VLC_SUCCESS)
-                return nil;
-
-            o_url = [NSURL fileURLWithPath: o_urlString];
+            BOOL b_autoplay = config_GetInt(VLCIntf, "macosx-autoplay");
+            NSURL * o_url = [NSURL fileURLWithPath: o_urlString];
             if (o_url != nil)
                 [[NSDocumentController sharedDocumentController] noteNewRecentDocumentURL: o_url];
+
+            NSMutableArray *o_result = [NSMutableArray arrayWithObject:[NSDictionary dictionaryWithObject:o_urlString forKey:@"ITEM_URL"]];
+
+            if (b_autoplay)
+                [[[VLCMain sharedInstance] playlist] appendArray: o_result atPos: -1 enqueue: NO];
+            else
+                [[[VLCMain sharedInstance] playlist] appendArray: o_result atPos: -1 enqueue: YES];
         }
     }
     return nil;