@@ -59,7 +59,7 @@ class ViewController: UIViewController {
59
59
self . navigationItem. rightBarButtonItem = UIBarButtonItem ( customView: connectionIndicatorView)
60
60
connectionIndicatorView. frame = CGRect ( origin: CGPoint ( ) , size: CGSize ( width: 20 , height: 20 ) )
61
61
62
- playPauseButton. setTitle ( " " , for: UIControl . State. normal) ;
62
+ playPauseButton. setTitle ( " " , for: UIControl . State. normal)
63
63
playPauseButton. setImage ( PlaybackButtonGraphics . playButtonImage ( ) , for: UIControl . State. normal)
64
64
playPauseButton. setImage ( PlaybackButtonGraphics . playButtonImage ( ) , for: UIControl . State. highlighted)
65
65
@@ -104,7 +104,7 @@ class ViewController: UIViewController {
104
104
105
105
if ( !enabled) {
106
106
albumArtImageView. image = nil
107
- updatePlayPauseButtonState ( true ) ;
107
+ updatePlayPauseButtonState ( true )
108
108
}
109
109
}
110
110
@@ -120,19 +120,19 @@ class ViewController: UIViewController {
120
120
121
121
private func updatePodcastSpeed( speed: SPTAppRemotePodcastPlaybackSpeed ) {
122
122
currentPodcastSpeed = speed
123
- podcastSpeedButton. setTitle ( String ( format: " %0.1fx " , speed. value. floatValue) , for: . normal) ;
123
+ podcastSpeedButton. setTitle ( String ( format: " %0.1fx " , speed. value. floatValue) , for: . normal)
124
124
}
125
125
126
126
// MARK: Player State
127
127
private func updatePlayPauseButtonState( _ paused: Bool ) {
128
128
let playPauseButtonImage = paused ? PlaybackButtonGraphics . playButtonImage ( ) : PlaybackButtonGraphics . pauseButtonImage ( )
129
- playPauseButton. setImage ( playPauseButtonImage, for: UIControl . State ( ) )
129
+ playPauseButton. setImage ( playPauseButtonImage, for: . normal )
130
130
playPauseButton. setImage ( playPauseButtonImage, for: . highlighted)
131
131
}
132
132
133
133
private func updatePlayerStateSubscriptionButtonState( ) {
134
134
let playerStateSubscriptionButtonTitle = subscribedToPlayerState ? " Unsubscribe " : " Subscribe "
135
- playerStateSubscriptionButton. setTitle ( playerStateSubscriptionButtonTitle, for: UIControl . State ( ) )
135
+ playerStateSubscriptionButton. setTitle ( playerStateSubscriptionButtonTitle, for: . normal )
136
136
}
137
137
138
138
// MARK: Capabilities
@@ -142,7 +142,7 @@ class ViewController: UIViewController {
142
142
143
143
private func updateCapabilitiesSubscriptionButtonState( ) {
144
144
let capabilitiesSubscriptionButtonTitle = subscribedToCapabilities ? " Unsubscribe " : " Subscribe "
145
- capabilitiesSubscriptionButton. setTitle ( capabilitiesSubscriptionButtonTitle, for: UIControl . State ( ) )
145
+ capabilitiesSubscriptionButton. setTitle ( capabilitiesSubscriptionButtonTitle, for: . normal )
146
146
}
147
147
148
148
// MARK: Shuffle
@@ -159,7 +159,7 @@ class ViewController: UIViewController {
159
159
case . context: return " Context "
160
160
default : return " Off "
161
161
}
162
- } ( )
162
+ } ( )
163
163
}
164
164
165
165
// MARK: Album Art
@@ -206,7 +206,7 @@ class ViewController: UIViewController {
206
206
private func pausePlayback( ) {
207
207
appRemote? . playerAPI? . pause ( defaultCallback)
208
208
}
209
-
209
+
210
210
private func playTrack( ) {
211
211
appRemote? . playerAPI? . play ( trackIdentifier, callback: defaultCallback)
212
212
}
@@ -357,9 +357,11 @@ class ViewController: UIViewController {
357
357
// MARK: - IBActions
358
358
@IBAction func didPressPlayPauseButton( _ sender: AnyObject ) {
359
359
if appRemote? . isConnected == false {
360
- if appRemote? . authorizeAndPlayURI ( playURI) == false {
361
- // The Spotify app is not installed, present the user with an App Store page
362
- showAppStoreInstall ( )
360
+ appRemote? . authorizeAndPlayURI ( playURI) { success in
361
+ if !success {
362
+ // The Spotify app is not installed, present the user with an App Store page
363
+ self . showAppStoreInstall ( )
364
+ }
363
365
}
364
366
} else if playerState == nil || playerState!. isPaused {
365
367
startPlayback ( )
@@ -430,9 +432,11 @@ class ViewController: UIViewController {
430
432
431
433
@IBAction func playRadioTapped( _ sender: Any ) {
432
434
if appRemote? . isConnected == false && appRemote? . playerAPI != nil {
433
- if appRemote? . authorizeAndPlayURI ( trackIdentifier, asRadio: true ) == false {
434
- // The Spotify app is not installed, present the user with an App Store page
435
- showAppStoreInstall ( )
435
+ appRemote? . authorizeAndPlayURI ( trackIdentifier, asRadio: true ) { success in
436
+ if !success {
437
+ // The Spotify app is not installed, present the user with an App Store page
438
+ self . showAppStoreInstall ( )
439
+ }
436
440
}
437
441
} else {
438
442
var trackUri = trackIdentifier
@@ -467,10 +471,10 @@ extension ViewController: SpeedPickerViewControllerDelegate {
467
471
468
472
// MARK: - SPTAppRemotePlayerStateDelegate
469
473
extension ViewController : SPTAppRemotePlayerStateDelegate {
470
- func playerStateDidChange( _ playerState: SPTAppRemotePlayerState ) {
471
- self . playerState = playerState
472
- updateViewWithPlayerState ( playerState)
473
- }
474
+ func playerStateDidChange( _ playerState: SPTAppRemotePlayerState ) {
475
+ self . playerState = playerState
476
+ updateViewWithPlayerState ( playerState)
477
+ }
474
478
}
475
479
// MARK: - SPTAppRemoteUserAPIDelegate
476
480
extension ViewController : SPTAppRemoteUserAPIDelegate {
0 commit comments