private void InitializeSpotify() { var scopes = new[] { SpotifyConstants.SPTAuthStreamingScope, SpotifyConstants.SPTAuthPlaylistReadPrivateScope, SpotifyConstants.SPTAuthUserLibraryReadScope, SpotifyConstants.SPTAuthUserReadPrivateScope }; _auth = SPTAuth.DefaultInstance; _spotifyPlayer = SPTAudioStreamingController.SharedInstance(); _auth.ClientID = ClientId; _auth.RequestedScopes = scopes; _auth.RedirectURL = _redirectUrl; _spotifyPlayer.Delegate = this; NSError error = null; try { _spotifyPlayer.StartWithClientId(ClientId, out error); } catch { Console.WriteLine(error); throw; } StartAuthenticationFlow(); }
public override void AudioStreamingDidLogin(SPTAudioStreamingController audioStreaming) { Debug.Write("Logged in successfully!", "stream"); this.Player.SetVolume(1, (arg0) => { }); AVAudioSession.SharedInstance().SetCategory(AVAudioSessionCategory.Playback); AVAudioSession.SharedInstance().SetActive(true); this.service.SomethingChanged(); }
public StreamingDelegate(SpotifyMusicServiceIos service) { NSNotificationCenter.DefaultCenter.AddObserver(new NSString("sessionUpdated"), (NSNotification obj) => { Debug.WriteLine("Got session updated notification", "stream"); this.service = service; var auth = SPTAuth.DefaultInstance; if (this.Player == null) { NSError error = null; this.Player = SPTAudioStreamingController.SharedInstance(); Debug.WriteLine("Player is " + this.Player == null ? "Null" : "Not null", "stream"); bool success = this.Player.StartWithClientId(auth.ClientID, null, SPOTIFY_CACHE_ENABLED, out error); if (success) { this.Player.Delegate = this; this.Player.PlaybackDelegate = new StreamingPlaybackDelegate(service); if (SPOTIFY_CACHE_ENABLED) { Debug.WriteLine("Spotify cache is enabled", "stream"); this.Player.DiskCache = new SPTDiskCache(1024 * 1024 * 64); } else { Debug.WriteLine("Spotify cache is disabled", "stream"); } } else { this.Player = null; Debug.WriteLine("*** Error: " + error.Description, "stream"); return; } } else { Debug.WriteLine("Player was already not null", "stream"); } Debug.WriteLine("Trying to login with access token", "stream"); this.Player.LoginWithAccessToken(auth.Session.AccessToken); this.service.SomethingChanged(); }); }
public override void AudioStreamingDidChangePlaybackStatus(SPTAudioStreamingController audioStreaming, bool isPlaying) { Debug.WriteLine("Playback changed: " + isPlaying, "playback"); if (isPlaying) { // This makes it so we can actually hear audio // I hate how long it took to figure this out AVAudioSession.SharedInstance().SetCategory(AVAudioSessionCategory.Playback); AVAudioSession.SharedInstance().SetActive(true); } else { AVAudioSession.SharedInstance().SetActive(false); } service.SomethingChanged(); }
public override void AudioStreamingDidChangePosition(SPTAudioStreamingController audioStreaming, double position) { //Debug.WriteLine("Position: " + position); service.SomethingChanged(); }
public override void AudioStreamingDidStopPlayingTrack(SPTAudioStreamingController audioStreaming, string trackUri) { Debug.WriteLine("Track ended: " + trackUri, "playback"); service.SomethingChanged(); service.SongEnds(trackUri); }
public override void AudioStreamingDidReceiveMessage(SPTAudioStreamingController audioStreaming, string message) { Debug.WriteLine("Message: " + message, "stream"); }
public override void AudioStreamingDidReceiveError(SPTAudioStreamingController audioStreaming, NSError error) { Debug.WriteLine("*** Error: " + error.Description, "stream"); }
public override void AudioStreamingDidLogout(SPTAudioStreamingController audioStreaming) { this.service.SomethingChanged(); }