public override RequestInitializationResult Initialize()
        {
            AudioRequestInitializationResult result = new AudioRequestInitializationResult();
            if (!Spotify.IsLoggedIn)
            {
                result.CanProceed = false;
                return result;
            }

            try
            {
                var track = new Track(Context.Data[0]);
                _trackPtr = track.TrackPtr;
            }
            catch
            {
                throw new MediaNotFoundException("Track not found.");
            }

            result.InputProperties = new AudioStreamProperties(MediaFormats.LPCM);
            result.CanProceed = true;
            result.IsConversion = this.Context.Format != MediaFormats.LPCM;
            result.SupportsSeeking = false;

            return result;
        }
Beispiel #2
0
        public override ServerObject GetMetadata()
        {
            Track t = new Track((IntPtr)this.ObjectData);

            AudioItem track = new AudioItem(new MediaServerLocation(typeof(SpotifyTrackHandler), new string[] { this.ObjectData.ToString() }), MediaFormats.LPCM);
            track.Title = t.Name;
            track.Artists.AddRange(t.Artists);
            track.Seconds = t.Seconds;
            track.TrackNumber = t.TrackNumber;
            if (t.Album != null) {
                track.Album = t.Album.Name;
                track.AlbumArtist = t.Album.Artist;
                track.AlbumArt = new ImageResource(new MediaServerLocation(typeof(AlbumArtHandler), new string[] { t.Album.AlbumPtr.ToString() }), MediaFormats.JPEG);
            }

            return track;
        }