* open.m: MacOS X plugin for vlc
*****************************************************************************
* Copyright (C) 2002 VideoLAN
- * $Id: open.m,v 1.9 2003/01/18 04:10:58 hartman Exp $
+ * $Id: open.m,v 1.21 2003/02/05 22:48:13 hartman Exp $
*
* Authors: Jon Lech Johansen <jon-vl@nanocrew.net>
* Christophe Massiot <massiot@via.ecp.fr>
+ * Derk-Jan Hartman <thedj@users.sourceforge.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
#include <IOKit/storage/IOCDMedia.h>
#include <IOKit/storage/IODVDMedia.h>
-#import <Cocoa/Cocoa.h>
-
-#include <vlc/vlc.h>
-#include <vlc/intf.h>
+#include "intf.h"
+#include "playlist.h"
+#include "open.h"
#include "netutils.h"
-#import "intf.h"
-#import "playlist.h"
-#import "open.h"
-
/*****************************************************************************
* GetEjectableMediaOfClass
*****************************************************************************/
[o_panel setTitle: _NS("Open Source")];
[o_mrl_lbl setTitle: _NS("Media Resource Locator (MRL)")];
+ [o_ckbox_enqueue setTitle: _NS("Only enqueue in playlist. Do not play.")];
[o_btn_ok setTitle: _NS("OK")];
[o_btn_cancel setTitle: _NS("Cancel")];
[o_file_btn_browse setTitle: _NS("Browse...")];
[o_file_stream setTitle: _NS("Treat as a pipe rather than as a file")];
+ [o_file_sub_btn_browse setTitle: _NS("Browse...")];
+ [o_file_sub_ckbox setTitle: _NS("Load subtitles")];
+
[o_disc_device_lbl setStringValue: _NS("Device name")];
[o_disc_title_lbl setStringValue: _NS("Title")];
[o_disc_chapter_lbl setStringValue: _NS("Chapter")];
- [o_disc_videots_btn_browse setStringValue: _NS("Browse...")];
- [o_disc_dvd_menus setTitle: _NS("Use DVD menus")];
+ [o_disc_videots_btn_browse setTitle: _NS("Browse...")];
+ [o_disc_dvd_menus setTitle: _NS("Use DVD menus (EXPERIMENTAL)")];
[[o_disc_type cellAtRow:0 column:0] setTitle: _NS("VIDEO_TS folder")];
[[o_disc_type cellAtRow:1 column:0] setTitle: _NS("DVD")];
[[o_sout_access cellAtRow:1 column:0] setTitle: _NS("UDP")];
[[o_sout_access cellAtRow:2 column:0] setTitle: _NS("RTP")];
- [o_sout_file_btn_browse setStringValue: _NS("Browse...")];
+ [o_sout_file_btn_browse setTitle: _NS("Browse...")];
[o_sout_udp_addr_lbl setStringValue: _NS("Address")];
[o_sout_udp_port_lbl setStringValue: _NS("Port")];
- [[o_sout_mux cellAtRow:0 column:0] setTitle: _NS("PS")];
- [[o_sout_mux cellAtRow:0 column:1] setTitle: _NS("TS")];
+ [[o_sout_mux cellAtRow:0 column:0] setTitle: _NS("AVI")];
+ [[o_sout_mux cellAtRow:0 column:1] setTitle: _NS("PS")];
+ [[o_sout_mux cellAtRow:0 column:2] setTitle: _NS("TS")];
[[NSNotificationCenter defaultCenter] addObserver: self
selector: @selector(openFilePathChanged:)
int i_result;
[o_tabview selectTabViewItemAtIndex: i_type];
-
+ [o_ckbox_enqueue setState: NSOnState];
+ [o_file_sub_path setStringValue: @""];
+ [o_file_sub_ckbox setState: NSOffState];
+ [o_file_sub_path setEnabled: NO];
+ [o_file_sub_btn_browse setEnabled: NO];
+
i_result = [NSApp runModalForWindow: o_panel];
[o_panel close];
if( i_result )
{
NSString *o_sout = [o_sout_mrl stringValue];
-
+ intf_thread_t * p_intf = [NSApp getIntf];
+
if ( [o_sout_cbox state] )
{
- intf_thread_t * p_intf = [NSApp getIntf];
config_PutPsz( p_intf, "sout", [o_sout lossyCString] );
}
NSString *o_source = [o_mrl stringValue];
-
+ BOOL b_enq = [o_ckbox_enqueue state] == NSOnState ? YES : NO;
+ NSString *subPath = [o_file_sub_path stringValue];
+
[o_playlist appendArray:
- [NSArray arrayWithObject: o_source] atPos: -1];
+ [NSArray arrayWithObject: o_source] atPos: -1 enqueue:b_enq];
+
+ if (([o_file_sub_ckbox state] == NSOnState) && !([subPath isEqualTo: @""]))
+ config_PutPsz( p_intf, "sub-file", strdup( [subPath cString] ) );
}
[self soutModeChanged: nil];
{
NSString *o_mrl_string;
NSString *o_filename = [o_file_path stringValue];
+ NSString *o_ext = [o_filename pathExtension];
vlc_bool_t b_stream = [o_file_stream state];
- o_mrl_string = [NSString stringWithFormat: @"%s://%@",
- b_stream ? "stream" : "file",
- o_filename];
+ if ([o_ext isEqualToString: @"bin"] ||
+ [o_ext isEqualToString: @"cue"] ||
+ [o_ext isEqualToString: @"vob"] ||
+ [o_ext isEqualToString: @"iso"])
+ {
+ o_mrl_string = o_filename;
+ }
+ else
+ {
+ o_mrl_string = [NSString stringWithFormat: @"%s://%@",
+ b_stream ? "stream" : "file",
+ o_filename];
+ }
[o_mrl setStringValue: o_mrl_string];
}
[self openFilePathChanged: nil];
}
+- (IBAction)loadSubsChanged:(id)sender
+{
+ if ([o_file_sub_ckbox state] == NSOnState)
+ {
+ [o_file_sub_path setEnabled:YES];
+ [o_file_sub_btn_browse setEnabled:YES];
+ }
+ else
+ {
+ [o_file_sub_path setEnabled:NO];
+ [o_file_sub_btn_browse setEnabled:NO];
+ }
+}
+
+- (IBAction)openSubBrowse:(id)sender
+{
+ NSOpenPanel *o_open_panel = [NSOpenPanel openPanel];
+
+ [o_open_panel setAllowsMultipleSelection: NO];
+ [o_open_panel setTitle: _NS("Open File")];
+ [o_open_panel setPrompt: _NS("Open")];
+
+ if( [o_open_panel runModalForDirectory: nil
+ file: nil types: nil] == NSOKButton )
+ {
+ NSString *o_filename = [[o_open_panel filenames] objectAtIndex: 0];
+ [o_file_sub_path setStringValue: o_filename];
+ }
+}
+
- (IBAction)openDiscTypeChanged:(id)sender
{
NSString *o_type;
{
NSString *o_mode;
BOOL b_file = FALSE;
- BOOL b_udp = FALSE;
- BOOL b_rtp = FALSE;
+ BOOL b_net = FALSE;
o_mode = [[o_sout_access selectedCell] title];
if( [o_mode isEqualToString: _NS("File")] ) b_file = TRUE;
- else if( [o_mode isEqualToString: _NS("UDP")] ) b_udp = TRUE;
- else if( [o_mode isEqualToString: _NS("RTP")] ) b_rtp = TRUE;
+ else if( [o_mode isEqualToString: _NS("UDP")] ) b_net = TRUE;
+ else if( [o_mode isEqualToString: _NS("RTP")] ) b_net = TRUE;
[o_sout_file_path setEnabled: b_file];
[o_sout_file_btn_browse setEnabled: b_file];
- [o_sout_udp_addr setEnabled: b_udp|b_rtp];
- [o_sout_udp_port setEnabled: b_udp|b_rtp];
- [o_sout_udp_port_stp setEnabled: b_udp|b_rtp];
- [[o_sout_mux cellAtRow:0 column: 0] setEnabled: !b_rtp];
+ [o_sout_udp_addr setEnabled: b_net];
+ [o_sout_udp_port setEnabled: b_net];
+ [o_sout_udp_port_stp setEnabled: b_net];
+ [[o_sout_mux cellAtRow:0 column: 0] setEnabled: !b_net];
+ [[o_sout_mux cellAtRow:0 column: 1] setEnabled: !b_net];
- if ( b_rtp )
+ if ( b_net )
{
- [[o_sout_mux cellAtRow: 0 column:1] setState: YES];
+ [[o_sout_mux cellAtRow: 0 column:2] setState: YES];
}
[self soutInfoChanged: nil];
o_mode = [[o_sout_access selectedCell] title];
o_mux = [[o_sout_mux selectedCell] title];
- if ( [o_mux isEqualToString: _NS("PS")] ) o_mux_string = @"ps";
+ if ( [o_mux isEqualToString: _NS("AVI")] ) o_mux_string = @"avi";
+ else if ( [o_mux isEqualToString: _NS("PS")] ) o_mux_string = @"ps";
else o_mux_string = @"ts";
if ( [o_mode isEqualToString: _NS("File")] )
- (IBAction)openFile:(id)sender
{
NSOpenPanel *o_open_panel = [NSOpenPanel openPanel];
-
- [o_open_panel setAllowsMultipleSelection: NO];
+
+ [o_open_panel setAllowsMultipleSelection: YES];
[o_open_panel setTitle: _NS("Open File")];
[o_open_panel setPrompt: _NS("Open")];
-
+
if( [o_open_panel runModalForDirectory: nil
file: nil types: nil] == NSOKButton )
{
intf_thread_t * p_intf = [NSApp getIntf];
config_PutPsz( p_intf, "sout", NULL );
- [o_playlist appendArray: [o_open_panel filenames] atPos: -1];
+ [o_playlist appendArray: [o_open_panel filenames] atPos: -1 enqueue:NO];
}
}
}
@end
+
+@implementation VLGetURLScriptCommand
+
+- (id)performDefaultImplementation {
+ NSString *o_command = [[self commandDescription] commandName];
+ NSString *o_urlString = [self directParameter];
+
+ NSLog(@"test1");
+ if ( [o_command isEqualToString:@"GetURL"] || [o_command isEqualToString:@"OpenURL"] )
+ {
+ intf_thread_t * p_intf = [NSApp getIntf];
+ NSLog( o_command );
+ playlist_t * p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
+ FIND_ANYWHERE );
+ if( p_playlist == NULL )
+ {
+ return nil;
+ }
+
+ if ( o_urlString )
+ {
+ NSURL * o_url;
+
+ int i_mode = PLAYLIST_INSERT | PLAYLIST_GO;
+
+ playlist_Add( p_playlist, [o_urlString fileSystemRepresentation],
+ i_mode, PLAYLIST_END );
+ NSLog( o_urlString );
+ o_url = [NSURL fileURLWithPath: o_urlString];
+ if( o_url != nil )
+ {
+ [[NSDocumentController sharedDocumentController]
+ noteNewRecentDocumentURL: o_url];
+ }
+ }
+ vlc_object_release( p_playlist );
+ }
+ return nil;
+}
+
+@end
+