Commit ff8183c0 authored by Jan Winter's avatar Jan Winter Committed by Felix Paul Kühne

OS X AppleScript: added new features

Signed-off-by: default avatarFelix Paul Kühne <fkuehne@videolan.org>
parent 0333f05e
......@@ -41,8 +41,22 @@
- (int)playbackRate;
- (void)next;
- (void)previous;
- (void)forward;
- (void)backward;
- (BOOL)isPlaying;
- (int)currentTime;
- (void)setCurrentTime:(int)i_value;
- (int)durationOfCurrentPlaylistItem;
- (NSURL*)URLOfCurrentPlaylistItem;
- (NSString*)nameOfCurrentPlaylistItem;
- (void)forward; //LEGACY SUPPORT
- (void)backward; //LEGACY SUPPORT
- (void)forwardExtraShort;
- (void)backwardExtraShort;
- (void)forwardShort;
- (void)backwardShort;
- (void)forwardMedium;
- (void)backwardMedium;
- (void)forwardLong;
- (void)backwardLong;
- (void)repeatOne;
- (void)repeatAll;
......@@ -52,7 +66,9 @@
- (void)volumeUp;
- (void)volumeDown;
- (void)mute;
- (void)setVolume: (int)i_value;
- (BOOL)isMuted;
- (int)volume;
- (void)setVolume:(int)i_value;
- (void)setAspectRatioLocked:(BOOL)b_value;
- (BOOL)aspectRatioIsLocked;
......
This diff is collapsed.
......@@ -21,6 +21,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
#import <Cocoa/Cocoa.h>
/*****************************************************************************
* VLGetURLScriptCommand interface
*****************************************************************************/
......@@ -40,4 +42,15 @@
- (BOOL)scriptFullscreenMode;
- (void)setScriptFullscreenMode: (BOOL)mode;
- (double)audioVolume;
- (void)setAudioVolume: (double)mode;
- (int)currentTime;
- (void)setCurrentTime: (int)mode;
- (int) durationOfCurrentItem;
- (NSString*) pathOfCurrentItem;
- (NSString*) nameOfCurrentItem;
@end
......@@ -27,6 +27,7 @@
#include "intf.h"
#include "applescript.h"
#include "CoreInteraction.h"
#include "vlc_aout_intf.h"
/*****************************************************************************
* VLGetURLScriptCommand implementation
......@@ -85,7 +86,8 @@
- (id)performDefaultImplementation {
NSString *o_command = [[self commandDescription] commandName];
NSString *o_parameter = [self directParameter];
intf_thread_t * p_intf = VLCIntf;
playlist_t * p_playlist = pl_Get( p_intf );
if( p_playlist == NULL )
......@@ -125,7 +127,67 @@
{
[[VLCCoreInteraction sharedInstance] volumeDown];
}
return nil;
else if ( [o_command isEqualToString:@"stepForward"] )
{
//default: forwardShort
if (o_parameter)
{
int i_parameter = [o_parameter intValue];
switch (i_parameter)
{
case 1:
[[VLCCoreInteraction sharedInstance] forwardExtraShort];
break;
case 2:
[[VLCCoreInteraction sharedInstance] forwardShort];
break;
case 3:
[[VLCCoreInteraction sharedInstance] forwardMedium];
break;
case 4:
[[VLCCoreInteraction sharedInstance] forwardLong];
break;
default:
[[VLCCoreInteraction sharedInstance] forwardShort];
break;
}
}
else
{
[[VLCCoreInteraction sharedInstance] forwardShort];
}
}
else if ( [o_command isEqualToString:@"stepBackward"] )
{
//default: backwardShort
if (o_parameter)
{
int i_parameter = [o_parameter intValue];
switch (i_parameter)
{
case 1:
[[VLCCoreInteraction sharedInstance] backwardExtraShort];
break;
case 2:
[[VLCCoreInteraction sharedInstance] backwardShort];
break;
case 3:
[[VLCCoreInteraction sharedInstance] backwardMedium];
break;
case 4:
[[VLCCoreInteraction sharedInstance] backwardLong];
break;
default:
[[VLCCoreInteraction sharedInstance] backwardShort];
break;
}
}
else
{
[[VLCCoreInteraction sharedInstance] backwardShort];
}
}
return nil;
}
@end
......@@ -156,4 +218,59 @@
[[VLCCoreInteraction sharedInstance] toggleFullscreen];
}
- (BOOL) muted {
return [[VLCCoreInteraction sharedInstance] isMuted];
}
- (BOOL) playing {
return [[VLCCoreInteraction sharedInstance] isPlaying];
}
- (double) audioVolume {
return ( (double)[[VLCCoreInteraction sharedInstance] volume] / (double)AOUT_VOLUME_DEFAULT );
}
- (void) setAudioVolume: (double) d_audioVolume {
//1 = 100%, 4 = 400%; 0 <= d_audioVolume <= 4
//0-1024 (but AOUT_VOLUME_MAX == 512)???
//AOUT_VOLUME_DEFAULT = 256 = 100%
//somehow [[VLCCoreInteraction sharedInstance] setVolume:i_parameter] has 0-32 steps with 32 as stepWidth (0 - 1024)
if (d_audioVolume < 0)
d_audioVolume = 0;
if (d_audioVolume > 4)
d_audioVolume = 4;
intf_thread_t * p_intf = VLCIntf;
playlist_t * p_playlist = pl_Get( VLCIntf );
int i_volume_step = config_GetInt( VLCIntf->p_libvlc, "volume-step" );
int i_parameter = (int) ( d_audioVolume * i_volume_step / 4 );
[[VLCCoreInteraction sharedInstance] setVolume:i_parameter];
}
- (int) currentTime {
return [[VLCCoreInteraction sharedInstance] currentTime];
}
- (void) setCurrentTime: (int) i_currentTime {
if (i_currentTime) {
[[VLCCoreInteraction sharedInstance] setCurrentTime:i_currentTime];
}
}
#pragma mark -
//TODO:whenever VLC should implement NSDocument, the methods below should move or be additionaly implemented in the NSDocument category
- (int) durationOfCurrentItem {
return [[VLCCoreInteraction sharedInstance] durationOfCurrentPlaylistItem];
}
- (NSString*) pathOfCurrentItem {
return [[[VLCCoreInteraction sharedInstance] URLOfCurrentPlaylistItem] path];
}
- (NSString*) nameOfCurrentItem {
return [[VLCCoreInteraction sharedInstance] nameOfCurrentPlaylistItem];
}
@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