예제 #1
0
        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();
            });
        }
예제 #2
0
 public StreamingPlaybackDelegate(SpotifyMusicServiceIos service)
 {
     this.service = service;
 }
예제 #3
0
 public SpotifyAuth(SpotifyMusicServiceIos service)
 {
     this.service = service;
 }