Exemplo n.º 1
0
        public async Task <Tuple <RadioPlaylist, IList <Song> > > CreateStationAsync(Song song)
        {
            var seedType = song.IsLibrary ? "TRACK_LOCKER_ID" : "TRACK_MATCHED_ID";
            var seedId   = song.ProviderSongId;

            var jsonProperties = new Dictionary <string, string>
            {
                { "seedId", JsonConvert.ToString(seedId) },
                { "seedType", JsonConvert.ToString(seedType) },
                { "name", JsonConvert.ToString(song.Title) }
            };

            var radioResp = await this.webService.PostAsync <FetchRadioFeedResp>(CreateStation, jsonProperties : jsonProperties);

            if (radioResp.Success.HasValue && !radioResp.Success.Value)
            {
                return(null);
            }

            RadioPlaylist playlist = new RadioPlaylist()
            {
                Id        = radioResp.Id,
                Title     = song.Title,
                TitleNorm = song.Title.Normalize(),
                SeedId    = seedId,
                SeedType  = seedType
            };

            return(Tuple.Create(playlist, await this.GetSongsAsync(radioResp)));
        }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            var playlist   = new RadioPlaylist();
            int songsCount = int.Parse(Console.ReadLine());

            for (int i = 0; i < songsCount; ++i)
            {
                try
                {
                    var songInputs = Console.ReadLine().Split(';');

                    string artist  = songInputs[0];
                    string name    = songInputs[1];
                    var    length  = songInputs[2].Split(':');
                    int    minutes = int.Parse(length[0]);
                    int    seconds = int.Parse(length[1]);

                    var song = new Song(artist, name, minutes, seconds);
                    playlist.AddSong(song);
                    Console.WriteLine("Song added.");
                }
                catch (InvalidSongException ex)
                {
                    Console.WriteLine(ex.Message);
                }
            }

            Console.WriteLine($"Songs added: {playlist.NumberOfSongs}");
            Console.WriteLine($"Playlist length: {playlist.Length:h'h 'm'm 's's'}");

            Console.ReadKey();
        }
Exemplo n.º 3
0
        public async Task RenameStationAsync(RadioPlaylist playlist, string name)
        {
            var jsonProperties = new Dictionary <string, string>
            {
                { "id", JsonConvert.ToString(playlist.Id) },
                { "name", JsonConvert.ToString(name) },
                { "radioSeedId", JsonConvert.SerializeObject(new { seedType = playlist.SeedType, seedId = playlist.SeedId }) }
            };

            await this.webService.PostAsync <CommonResponse>(RenameStation, jsonProperties : jsonProperties);
        }
 public RadioEditPopupViewPresenter(
     ISearchService searchService,
     IRadioWebService radioWebService,
     RadioPlaylist radioPlaylist)
 {
     this.searchService   = searchService;
     this.radioWebService = radioWebService;
     this.radioPlaylist   = radioPlaylist;
     this.SaveCommand     = new DelegateCommand(this.Save, this.CanSave);
     this.CancelCommand   = new DelegateCommand(this.Cancel);
     this.Title           = radioPlaylist.Title;
 }
Exemplo n.º 5
0
        public override HRESULT GetURI(out string uri)
        {
            string str = null;

            if (this._playlist == null && this._originalUri != null)
            {
                this._playlist = RadioStationManager.Instance.GetRadioPlaylist(this._originalUri);
            }
            if (this._playlist != null)
            {
                str = this._playlist.GetNextUri();
            }
            uri = str;
            return(HRESULT._S_OK);
        }
Exemplo n.º 6
0
        private RadioPlaylist ConvertToPlaylist(GoogleRadio googleRadio)
        {
            var radioPlaylist = new RadioPlaylist()
            {
                Id         = googleRadio.Id,
                Title      = googleRadio.Name,
                TitleNorm  = googleRadio.Name.Normalize(),
                LastPlayed = DateTimeExtensions.FromUnixFileTime(googleRadio.RecentTimestamp / 1000)
            };

            if (googleRadio.ImageUrl != null && googleRadio.ImageUrl.Length > 0)
            {
                radioPlaylist.ArtUrl = new Uri(googleRadio.ImageUrl[0]);
            }

            if (googleRadio.RadioSeedId != null)
            {
                radioPlaylist.SeedId   = googleRadio.RadioSeedId.SeedId;
                radioPlaylist.SeedType = googleRadio.RadioSeedId.SeedType;
            }

            return(radioPlaylist);
        }