2016-07-04 5 views
0

스크립팅 브리지를 사용하여 osx 응용 프로그램에서 Spotify를 제어하고 있습니다. ScriptingBridge -> 속성에 할당 할 수 없습니다 : 'self'는 변경 불가능

spotify.soundVolume = 10 

나는

cannot assign to property: 'self' is immutable 

내가 잘못 뭐하는 거지 오류를 얻을 : 내가하려고 할 때 다음

var spotify: AnyObject = SBApplication(bundleIdentifier: "com.spotify.client")! 

:

그래서 같은 응용 프로그램 개체를 만드는 오전 ? 나는 스포티 파이의 설명서에 따라 볼륨을 설정 할 수 있어야한다 :

spotify.setValue (sender.integerValue, forKey : https://developer.spotify.com/applescript-api/

/* 
* Spotify.h 
*/ 

#import <AppKit/AppKit.h> 
#import <ScriptingBridge/ScriptingBridge.h> 


@class SpotifyApplication, SpotifyTrack, SpotifyApplication; 

enum SpotifyEPlS { 
    SpotifyEPlSStopped = 'kPSS', 
    SpotifyEPlSPlaying = 'kPSP', 
    SpotifyEPlSPaused = 'kPSp' 
}; 
typedef enum SpotifyEPlS SpotifyEPlS; 



/* 
* Spotify Suite 
*/ 

// The Spotify application. 
@interface SpotifyApplication : SBApplication 

@property (copy, readonly) SpotifyTrack *currentTrack; // The current playing track. 
@property NSInteger soundVolume; // The sound output volume (0 = minimum, 100 = maximum) 
@property (readonly) SpotifyEPlS playerState; // Is Spotify stopped, paused, or playing? 
@property double playerPosition; // The player’s position within the currently playing track in seconds. 
@property (readonly) BOOL repeatingEnabled; // Is repeating enabled in the current playback context? 
@property BOOL repeating; // Is repeating on or off? 
@property (readonly) BOOL shufflingEnabled; // Is shuffling enabled in the current playback context? 
@property BOOL shuffling; // Is shuffling on or off? 

- (void) nextTrack; // Skip to the next track. 
- (void) previousTrack; // Skip to the previous track. 
- (void) playpause; // Toggle play/pause. 
- (void) pause; // Pause playback. 
- (void) play; // Resume playback. 
- (void) playTrack:(NSString *)x inContext:(NSString *)inContext; // Start playback of a track in the given context. 

@end 

// A Spotify track. 
@interface SpotifyTrack : SBObject 

@property (copy, readonly) NSString *artist; // The artist of the track. 
@property (copy, readonly) NSString *album; // The album of the track. 
@property (readonly) NSInteger discNumber; // The disc number of the track. 
@property (readonly) NSInteger duration; // The length of the track in seconds. 
@property (readonly) NSInteger playedCount; // The number of times this track has been played. 
@property (readonly) NSInteger trackNumber; // The index of the track in its album. 
@property (readonly) BOOL starred; // Is the track starred? 
@property (readonly) NSInteger popularity; // How popular is this track? 0-100 
- (NSString *) id; // The ID of the item. 
@property (copy, readonly) NSString *name; // The name of the track. 
@property (copy, readonly) NSString *artworkUrl; // The URL of the track%apos;s album cover. 
@property (copy, readonly) NSImage *artwork; // The property is deprecated and will never be set. Use the 'artwork url' instead. 
@property (copy, readonly) NSString *albumArtist; // That album artist of the track. 
@property (copy) NSString *spotifyUrl; // The URL of the track. 


@end 



/* 
* Standard Suite 
*/ 

// The application's top level scripting object. 
@interface SpotifyApplication (StandardSuite) 

@property (copy, readonly) NSString *name; // The name of the application. 
@property (readonly) BOOL frontmost; // Is this the frontmost (active) application? 
@property (copy, readonly) NSString *version; // The version of the application. 

@end 
+0

신속한 코드를 표시하십시오. – Alexander

+0

나는 단지 2 개의 관련 선을 보여줬다. ..? – user3916570

+0

'spotify.soundVolume = 10'은 어디에서 실행합니까? mutable (mutating func ...')으로 표시 할 필요가있을 때를 대비하여 _structure_ ('struct') 메소드에서이 시도 된 돌연변이를 수행하고있는 것 같습니다. – dfri

답변

1

그것은 실행 가능한 옵션을 끈다는 실제로 같은 것을 할 " soundVolume ")

관련 문제