Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Using ScriptingBridge from Swift.
#! /usr/bin/swift
import ScriptingBridge
@objc protocol iTunesTrack {
optional var name: String {get}
optional var album: String {get}
}
@objc protocol iTunesApplication {
optional var soundVolume: Int {get}
optional var currentTrack: iTunesTrack? {get}
}
extension SBApplication : iTunesApplication {}
let app: iTunesApplication = SBApplication(bundleIdentifier: "com.apple.iTunes")
// Because these are all optional properties (to avoid providing an implementation), we have
// to use '!' to indicate we know the implementation exists.
let track: iTunesTrack? = app.currentTrack!
let album = track?.album!
let trackName = track?.name!
println("Current track: \(trackName) - \(album)")
@jonathanstiansen

This comment has been minimized.

Copy link

@jonathanstiansen jonathanstiansen commented Nov 3, 2015

Any shot you know how to do a function for these?

@chess92

This comment has been minimized.

Copy link

@chess92 chess92 commented May 17, 2016

How can you check if iTunes is currently playing audio?

@aphofstede

This comment has been minimized.

Copy link

@aphofstede aphofstede commented Sep 9, 2016

What would the iTunesApplication protocol look like if one wanted to call a function call on it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.