-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSpotify.swift
66 lines (60 loc) · 3.82 KB
/
Spotify.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
import AppKit
import ScriptingBridge
@objc public protocol SpotifyObjectProtocol: NSObjectProtocol {
func get() -> AnyObject!
}
@objc public protocol SpotifyApplicationProtocol: SpotifyObjectProtocol {
func activate()
var delegate: SBApplicationDelegate! { get set }
var running: Bool { @objc(isRunning) get }
}
// MARK: SpotifyEPlS
@objc public enum SpotifyEPlS : AEKeyword {
case Stopped = 0x6b505353 /* 'kPSS' */
case Playing = 0x6b505350 /* 'kPSP' */
case Paused = 0x6b505370 /* 'kPSp' */
}
// MARK: SpotifyApplication
@objc public protocol SpotifyApplication: SpotifyApplicationProtocol {
@objc optional var currentTrack: SpotifyTrack { get } // The current playing track.
@objc optional var soundVolume: Int { get } // The sound output volume (0 = minimum, 100 = maximum)
@objc optional var playerState: SpotifyEPlS { get } // Is Spotify stopped, paused, or playing?
@objc optional var playerPosition: Double { get } // The player’s position within the currently playing track in seconds.
@objc optional var repeatingEnabled: Bool { get } // Is repeating enabled in the current playback context?
@objc optional var repeating: Bool { get } // Is repeating on or off?
@objc optional var shufflingEnabled: Bool { get } // Is shuffling enabled in the current playback context?
@objc optional var shuffling: Bool { get } // Is shuffling on or off?
@objc optional func nextTrack() // Skip to the next track.
@objc optional func previousTrack() // Skip to the previous track.
@objc optional func playpause() // Toggle play/pause.
@objc optional func pause() // Pause playback.
@objc optional func play() // Resume playback.
@objc optional func playTrack(x: String!, inContext: String!) // Start playback of a track in the given context.
@objc optional func setSoundVolume(soundVolume: Int) // The sound output volume (0 = minimum, 100 = maximum)
@objc optional func setPlayerPosition(playerPosition: Double) // The player’s position within the currently playing track in seconds.
@objc optional func setRepeating(repeating: Bool) // Is repeating on or off?
@objc optional func setShuffling(shuffling: Bool) // Is shuffling on or off?
@objc optional var name: String { get } // The name of the application.
@objc optional var frontmost: Bool { get } // Is this the frontmost (active) application?
@objc optional var version: String { get } // The version of the application.
}
extension SBApplication: SpotifyApplication {}
// MARK: SpotifyTrack
@objc public protocol SpotifyTrack: SpotifyObjectProtocol {
@objc optional var artist: String { get } // The artist of the track.
@objc optional var album: String { get } // The album of the track.
@objc optional var discNumber: Int { get } // The disc number of the track.
@objc optional var duration: Int { get } // The length of the track in seconds.
@objc optional var playedCount: Int { get } // The number of times this track has been played.
@objc optional var trackNumber: Int { get } // The index of the track in its album.
@objc optional var starred: Bool { get } // Is the track starred?
@objc optional var popularity: Int { get } // How popular is this track? 0-100
@objc optional func id() -> String // The ID of the item.
@objc optional var name: String { get } // The name of the track.
@objc optional var artworkUrl: String { get } // The URL of the track%apos;s album cover.
@objc optional var artwork: NSImage { get } // The property is deprecated and will never be set. Use the 'artwork url' instead.
@objc optional var albumArtist: String { get } // That album artist of the track.
@objc optional var spotifyUrl: String { get } // The URL of the track.
@objc optional func setSpotifyUrl(spotifyUrl: String!) // The URL of the track.
}
extension SBObject: SpotifyTrack {}