Created
September 21, 2012 20:28
-
-
Save Alxandr/3763712 to your computer and use it in GitHub Desktop.
Sample async SpotiFire usage
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Console.WriteLine("Enter username and password (a line for each)"); | |
| ISession session = await Spotify.CreateSession(key, cache, settings, userAgent); | |
| session.MusicDeliver += session_MusicDeliver; | |
| await session.Login(Console.ReadLine(), Console.ReadLine(), false); | |
| session.SetPrefferedBitrate(sp_bitrate.BITRATE_320k); | |
| await session.PlaylistContainer; | |
| var playlist = await session.PlaylistContainer[0]; | |
| Console.WriteLine("Playing first from " + playlist.Name); | |
| var track = await playlist[0]; | |
| await session.Play(track); | |
| playlist = await session.Starred; | |
| Console.WriteLine("Playing first starred track"); | |
| track = await playlist[0]; | |
| Console.WriteLine("Found track " + track.Name); | |
| await session.Play(track); | |
| Console.WriteLine("Enter song search"); | |
| var search = await session.SearchTracks(Console.ReadLine(), 0, 1); | |
| if (search.Tracks.Count > 0) | |
| { | |
| track = await search.Tracks[0]; | |
| Console.WriteLine("Playing " + track.Name); | |
| await session.Play(track); | |
| } | |
| else | |
| { | |
| Console.WriteLine("No matching tracks."); | |
| } | |
| await session.Logout(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment