Commit bd4d55d7 authored by Florian G. Pflug's avatar Florian G. Pflug

Made it possible to open a File after vlc was started (you can use vlc now

without starting it from the command line)

Cleaned up playlist handling in Intf_Vlc_Wrapper.
parent 52945c01
......@@ -58,13 +58,13 @@
- (void)applicationDidBecomeActive:(NSNotification*)aNotification {
if (b_window_is_fullscreen) {
[o_window orderFront:self] ;
[o_vlc play] ;
[o_vlc playlistPlayCurrent] ;
}
}
- (void)applicationDidResignActive:(NSNotification*)aNotification {
if (b_window_is_fullscreen) {
[o_vlc pause] ;
[o_vlc playlistPause] ;
[o_window orderOut:self] ;
}
}
......@@ -72,13 +72,28 @@
//Functions attached to user interface
//Functions attached to user interface
- (IBAction) openFile:(id)sender {
NSOpenPanel *o_panel = [NSOpenPanel openPanel] ;
[o_panel setAllowsMultipleSelection:YES] ;
if ([o_panel runModalForDirectory:NSHomeDirectory() file:nil types:nil] == NSOKButton) {
NSEnumerator* o_files = [[o_panel filenames] objectEnumerator] ;
NSString* o_file ;
while ((o_file = (NSString*)[o_files nextObject])) {
[o_vlc playlistAdd:o_file] ;
}
}
[o_vlc playlistPlayCurrent] ;
}
- (IBAction) pause:(id)sender {
[o_vlc pause] ;
[o_vlc playlistPause] ;
}
- (IBAction) play:(id)sender {
[o_vlc play] ;
[o_vlc playlistPlayCurrent] ;
}
- (IBAction) timeslider_update:(id)slider {
......@@ -168,21 +183,11 @@
@implementation Intf_PlaylistDS
- (void ) awakeFromNib {
o_vlc = [Intf_VlcWrapper instance] ;
o_playlist = [[NSMutableArray arrayWithCapacity:10] retain] ;
o_playlist = nil ;
}
- (void) readPlaylist {
static unsigned int i_length_old = 0;
unsigned int i ;
if (i_length_old == [o_vlc getPlaylistLength])
return ;
[o_playlist removeAllObjects] ;
[o_vlc lockPlaylist] ;
for(i=0; i < [o_vlc getPlaylistLength]; i++)
[o_playlist addObject:[o_vlc getPlaylistItem:i]] ;
[o_vlc unlockPlaylist] ;
o_playlist = [[o_vlc playlistAsArray] retain] ;
}
- (int) numberOfRowsInTableView:(NSTableView*)o_table {
......
......@@ -65,6 +65,7 @@
- (void)applicationDidResignActive:(NSNotification*)aNotification ;
//Functions atteched to user interface
- (IBAction) openFile:(id)sender ;
- (IBAction) pause:(id)sender ;
- (IBAction) play:(id)sender ;
- (IBAction) timeslider_update:(id)slider ;
......
......@@ -54,6 +54,11 @@
#define p_area p_main->p_intf->p_input->stream.p_selected_area
@interface Intf_VlcWrapper(Private)
- (struct vout_thread_s*) lockVout ;
- (void) unlockVout ;
@end
@implementation Intf_VlcWrapper
//Initialization,.....
+ (Intf_VlcWrapper*) instance {
......@@ -139,63 +144,28 @@
//Playback control
- (void) play {
if (![self hasInput]) return ;
switch (e_speed)
{
case SPEED_SLOW:
input_SetStatus(p_main->p_intf->p_input, INPUT_STATUS_SLOWER) ;
break ;
case SPEED_NORMAL:
input_SetStatus(p_main->p_intf->p_input, INPUT_STATUS_PLAY) ;
break ;
case SPEED_FAST:
input_SetStatus(p_main->p_intf->p_input, INPUT_STATUS_FASTER) ;
break ;
}
}
- (void) pause {
if (![self hasInput]) return ;
input_SetStatus(p_main->p_intf->p_input, INPUT_STATUS_PAUSE) ;
}
- (void) stop {
return ;
}
- (void) stepf {
return ;
}
- (void) stepr {
return ;
}
- (void) setSpeed:(intf_speed_t) _e_speed {
e_speed = _e_speed ;
[self play] ;
[self playlistPlayCurrent] ;
}
- (NSString *) getTimeAsString {
static char psz_currenttime[ OFFSETTOTIME_MAX_SIZE ] ;
if (![self hasInput]) return [NSString stringWithCString:"00:00:00"] ;
if (!p_main->p_intf->p_input) return [NSString stringWithCString:"00:00:00"] ;
input_OffsetToTime( p_main->p_intf->p_input, psz_currenttime, p_area->i_tell ) ;
return [NSString stringWithCString:psz_currenttime] ;
}
- (float) getTimeAsFloat {
if (![self hasInput]) return 0.0 ;
if (!p_main->p_intf->p_input) return 0.0 ;
return (float)p_area->i_tell / (float)p_area->i_size ;
}
- (void) setTimeAsFloat:(float) f_position {
if (![self hasInput]) return ;
if (!p_main->p_intf->p_input) return ;
input_Seek(p_main->p_intf->p_input, p_area->i_size * f_position) ;
}
......@@ -204,45 +174,114 @@
//Playlist control
- (void) lockPlaylist {
- (NSArray*) playlistAsArray {
NSMutableArray* p_list = [NSMutableArray arrayWithCapacity:p_main->p_playlist->i_size] ;
int i ;
vlc_mutex_lock(&p_main->p_playlist->change_lock) ;
for (i=0; i < p_main->p_playlist->i_size; i++)
[p_list addObject:[NSString stringWithCString:p_main->p_playlist->p_item[i].psz_name]] ;
vlc_mutex_unlock(&p_main->p_playlist->change_lock) ;
return [NSArray arrayWithArray:p_list] ;
}
- (int) playlistLength {
return p_main->p_playlist->i_size ;
}
- (NSString*) playlistItem:(int) i_pos {
NSString* o_item = nil ;
- (void) unlockPlaylist {
vlc_mutex_lock(&p_main->p_playlist->change_lock) ;
if (i_pos < p_main->p_playlist->i_size)
o_item = [NSString stringWithCString:p_main->p_playlist->p_item[i_pos].psz_name] ;
vlc_mutex_unlock(&p_main->p_playlist->change_lock) ;
return o_item ;
}
- (int) getPlaylistLength {
return p_main->p_playlist->i_size ;
- (bool) playlistPlayCurrent {
if (p_main->p_intf->p_input) {
switch (e_speed)
{
case SPEED_SLOW:
input_SetStatus(p_main->p_intf->p_input, INPUT_STATUS_SLOWER) ;
break ;
case SPEED_NORMAL:
input_SetStatus(p_main->p_intf->p_input, INPUT_STATUS_PLAY) ;
break ;
case SPEED_FAST:
input_SetStatus(p_main->p_intf->p_input, INPUT_STATUS_FASTER) ;
break ;
}
p_main->p_playlist->b_stopped = 0 ;
}
else if (p_main->p_playlist->b_stopped) {
if (p_main->p_playlist->i_size)
intf_PlaylistJumpto(p_main->p_playlist, p_main->p_playlist->i_index) ;
else
return FALSE ;
}
return TRUE ;
}
- (void) playlistPause {
if (p_main->p_intf->p_input)
input_SetStatus(p_main->p_intf->p_input, INPUT_STATUS_PAUSE) ;
}
- (NSString*) getPlaylistItem:(int) i_pos {
if (i_pos >= p_main->p_playlist->i_size)
return nil ;
return [NSString stringWithCString:p_main->p_playlist->p_item[i_pos].psz_name] ;
- (void) playlistStop {
if (p_main->p_intf->p_input) p_main->p_intf->p_input->b_eof = 1 ;
vlc_mutex_lock(&p_main->p_playlist->change_lock) ;
p_main->p_playlist->i_index-- ;
p_main->p_playlist->b_stopped = 1 ;
vlc_mutex_unlock(&p_main->p_playlist->change_lock) ;
}
- (void) playNextPlaylistItem {
intf_PlaylistNext(p_main->p_playlist) ;
- (void) playlistPlayNext {
[self playlistStop] ;
vlc_mutex_lock(&p_main->p_playlist->change_lock) ;
p_main->p_playlist->i_index++ ;
vlc_mutex_unlock(&p_main->p_playlist->change_lock) ;
[self playlistPlayCurrent] ;
}
- (void) playPrevPlaylistItem {
intf_PlaylistPrev(p_main->p_playlist) ;
- (void) playlistPlayPrev {
[self playlistStop] ;
vlc_mutex_lock(&p_main->p_playlist->change_lock) ;
p_main->p_playlist->i_index-- ;
vlc_mutex_unlock(&p_main->p_playlist->change_lock) ;
[self playlistPlayCurrent] ;
}
- (void) playlistPlayItem:(int)i_item {
[self playlistStop] ;
vlc_mutex_lock(&p_main->p_playlist->change_lock) ;
if (i_item < p_main->p_playlist->i_size)
p_main->p_playlist->i_index-- ;
vlc_mutex_unlock(&p_main->p_playlist->change_lock) ;
[self playlistPlayCurrent] ;
}
- (void) addPlaylistItem:(NSString*)o_filename {
- (void) playlistAdd:(NSString*)o_filename {
intf_PlaylistAdd(p_main->p_playlist, PLAYLIST_END, [o_filename lossyCString]) ;
}
- (void) clearPlaylist {
int i ;
vlc_mutex_lock(&p_main->p_playlist->change_lock) ;
for(i=0; i < p_main->p_playlist->i_size; i++)
intf_PlaylistDelete(p_main->p_playlist, i) ;
vlc_mutex_unlock(&p_main->p_playlist->change_lock) ;
}
// Private Functions. This are just some utilities for other functions
- (bool) hasInput {
return (p_main->p_intf->p_input != NULL) ? TRUE : FALSE ;
}
- (struct vout_thread_s*) lockVout {
vlc_mutex_lock(&p_vout_bank->lock) ;
if (p_vout_bank->i_count) {
......
......@@ -23,7 +23,6 @@
#import <Cocoa/Cocoa.h>
struct vlc_thread_s ;
typedef enum intf_speed_e {SPEED_SLOW=0, SPEED_NORMAL, SPEED_FAST} intf_speed_t ;
@protocol VlcWrapper_Delegate
- (void) requestQDPortFullscreen:(bool)b_fullscreen ;
......@@ -52,28 +51,22 @@ typedef enum intf_speed_e {SPEED_SLOW=0, SPEED_NORMAL, SPEED_FAST} intf_speed_t
- (NSSize) videoSize ;
// Playback control
- (void) play ;
- (void) pause ;
- (void) stop ;
- (void) stepf ;
- (void) stepr ;
- (void) setSpeed:(intf_speed_t)e_speed ;
- (NSString*) getTimeAsString ;
- (float) getTimeAsFloat ;
- (void) setTimeAsFloat:(float)i_offset ;
// Playlist control
- (void) lockPlaylist ;
- (void) unlockPlaylist ;
- (int) getPlaylistLength ;
- (NSString*) getPlaylistItem:(int)i_pos ;
- (void) playNextPlaylistItem ;
- (void) playPrevPlaylistItem ;
- (void) addPlaylistItem:(NSString*)o_filename ;
//private
- (bool) hasInput ;
- (struct vout_thread_s*) lockVout ;
- (void) unlockVout ;
- (NSArray*) playlistAsArray ;
- (int) playlistLength ;
- (NSString*) playlistItem:(int) i_pos ;
- (bool) playlistPlayCurrent ;
- (void) playlistPause ;
- (void) playlistStop ;
- (void) playlistPlayNext ;
- (void) playlistPlayPrev ;
- (void) playlistPlayItem:(int)i_item ;
- (void) playlistAdd:(NSString*)o_filename ;
- (void) clearPlaylist ;
@end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment