[vlc-commits] macosx: re-write and simplify the apple event handlers for GetURL and OpenURL, make it respect 'macosx-autoplay' (close #6319)

Felix Paul Kühne git at videolan.org
Sat Mar 9 17:21:44 CET 2013


vlc | branch: master | Felix Paul Kühne <fkuehne at videolan.org> | Sat Mar  9 17:13:48 2013 +0100| [5f5167f1ea582beca09e4a45d6544b056a4c15ad] | committer: Felix Paul Kühne

macosx: re-write and simplify the apple event handlers for GetURL and OpenURL, make it respect 'macosx-autoplay' (close #6319)

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

 NEWS                             |    2 ++
 modules/gui/macosx/applescript.m |   39 ++++++++++++++------------------------
 2 files changed, 16 insertions(+), 25 deletions(-)

diff --git a/NEWS b/NEWS
index 70b7e78..ef2f432 100644
--- 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
 
diff --git a/modules/gui/macosx/applescript.m b/modules/gui/macosx/applescript.m
index d9082ca..bff1f31 100644
--- a/modules/gui/macosx/applescript.m
+++ b/modules/gui/macosx/applescript.m
@@ -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 at users.sourceforge.net>
@@ -25,9 +25,10 @@
 /*****************************************************************************
  * Preamble
  *****************************************************************************/
-#include "intf.h"
-#include "applescript.h"
-#include "CoreInteraction.h"
+#import "intf.h"
+#import "applescript.h"
+#import "CoreInteraction.h"
+#import "playlist.h"
 
 /*****************************************************************************
  * VLGetURLScriptCommand implementation
@@ -39,30 +40,18 @@
     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;



More information about the vlc-commits mailing list