Пример #1
0
        public void SendProgressUpdate(Song song, QueryTrackProgress progress)
        {
            foreach (var obj in _pcqList)
            {
                var prog = new QueryProgress()
                {
                    Song = new QuerySong()
                    {
                        Artist = song.Artist,
                        Album = song.Album,
                        Title = song.SongTitle,
                        Meta = song.GetMetaObject(obj)
                    },
                    Progress = progress
                };

                obj.ProgressUpdateReciever(prog);
            }
        }
Пример #2
0
 private void SetSong(Song song)
 {
     CurrentSong.Content = song;
     CurrentSong.Visibility = Visibility.Visible;
     WaitScreen.Visibility = Visibility.Collapsed;
 }
Пример #3
0
 public Station CreateStationFromSong(Song song)
 {
     return CreateStation(song, "song");
 }
Пример #4
0
 public void CallFeedbackUpdateEvent(Song song, bool success)
 {
     if (FeedbackUpdateEvent != null)
         FeedbackUpdateEvent(this, song, success);
 }
Пример #5
0
 private void _playlist_PlayedSongDequeued(object sender, Song oldSong)
 {
     if (PlayedSongRemoved != null)
         PlayedSongRemoved(this, oldSong);
 }
Пример #6
0
 private void RateSong(Song song, SongRating rating)
 {
     if (_isRating) return;
     _isRating = true;
     SongRating oldRating = song.Rating;
     song.Rate(rating);
     _cqman.SendRatingUpdate(song.Artist, song.Album, song.SongTitle, oldRating, rating);
     _isRating = false;
 }
Пример #7
0
 public void SongThumbUp(Song song)
 {
     if (!IsStationLoaded) return;
     RunTask(() => RateSong(song, SongRating.love));
 }
Пример #8
0
 public void SongDeleteFeedback(Song song)
 {
     if (!IsStationLoaded) return;
     RunTask(() => RateSong(song, SongRating.none));
 }
Пример #9
0
 private void btnMenu_Click(object sender, RoutedEventArgs e)
 {
     _currMenuSong = GetItemSong(sender);
     ShowMenu(sender);
 }
Пример #10
0
 public void SendProgressUpdate(Song song, TimeSpan TotalTime, TimeSpan ElapsedTime)
 {
     SendProgressUpdate(song, new QueryTrackProgress() { TotalTime = TotalTime, ElapsedTime = ElapsedTime });
 }
Пример #11
0
        public ControlQueryManager()
        {
            _lastQuerySong = null;

            _pcqList = new List<IPlayerControlQuery>();
        }
Пример #12
0
        public void SendSongUpdate(Song song)
        {
            lock (_lastQuerySongLock)
            {
                _lastQuerySong = song;
            }

            Log.O("Song Update: {0} | {1} | {2}", song.Artist, song.Album, song.SongTitle);
            foreach (var obj in _pcqList)
            {
                obj.SongUpdateReceiver(new QuerySong()
                {
                    Artist = song.Artist,
                    Album = song.Album,
                    Title = song.SongTitle,
                    Meta = song.GetMetaObject(obj)
                });
            }
        }
        private List<Song> ParseSongXml(string xml)
        {
            try
            {
                List<Song> songs = new List<Song>();

                XmlDocument xmlDoc = new XmlDocument();
                xmlDoc.LoadXml(xml);

                XmlNodeList songNodes = xmlDoc.SelectNodes("/methodResponse/params/param/value/array/data/value");

                foreach (XmlNode songNode in songNodes)
                {
                    XmlNode albumTitleNode = songNode.SelectSingleNode("struct/member[name='albumTitle']/value");
                    XmlNode artistSummaryNode = songNode.SelectSingleNode("struct/member[name='artistSummary']/value");
                    XmlNode artRadioNode = songNode.SelectSingleNode("struct/member[name='artRadio']/value");
                    XmlNode audioUrlNode = songNode.SelectSingleNode("struct/member[name='audioURL']/value");
                    XmlNode songTitleNode = songNode.SelectSingleNode("struct/member[name='songTitle']/value");
                    XmlNode ratingNode = songNode.SelectSingleNode("struct/member[name='rating']/value");
                    XmlNode stationIdNode = songNode.SelectSingleNode("struct/member[name='stationId']/value");
                    XmlNode musicIdNode = songNode.SelectSingleNode("struct/member[name='musicId']/value");
                    XmlNode userSeedNode = songNode.SelectSingleNode("struct/member[name='userSeed']/value");
                    XmlNode songTypeNode = songNode.SelectSingleNode("struct/member[name='songType']/value/int");

                    Song song = new Song();
                    song.AlbumTitle = albumTitleNode.InnerText;
                    song.ArtistSummary = artistSummaryNode.InnerText;
                    song.ArtRadio = artRadioNode.InnerText;
                    song.AudioUrl = audioUrlNode.InnerText;
                    song.SongTitle = songTitleNode.InnerText;
                    song.Like = ratingNode.InnerText == "1" ? true : false;
                    song.StationId = stationIdNode.InnerText;
                    song.MusicId = musicIdNode.InnerText;
                    song.UserSeed = userSeedNode.InnerText;
                    song.SongType = int.Parse(songTypeNode.InnerText);
                    songs.Add(song);
                }

                return songs;
            }
            catch (Exception exception)
            {
                throw new Exception("Unable to parse Song XML.", exception);
            }
        }
        public void SubmitFeedbackAsync(Song song, Ratings rating)
        {
            try
            {
                WebClient client = new WebClient();
                client.Headers.Add("content-type", "text-xml");
                client.UploadDataCompleted += new UploadDataCompletedEventHandler(SubmitFeedback_UploadDataCompleted);
                Uri uri = new Uri(String.Format(BASE_URL_LID, _rid, _lid, "addFeedback"));

                List<object> parameters = new List<object>();
                parameters.Add(GetTimestamp());
                parameters.Add(_authenticationToken);
                parameters.Add(song.StationId);
                parameters.Add(song.MusicId);
                parameters.Add(song.UserSeed);
                parameters.Add(String.Empty);//TestStrategy--wtf?
                parameters.Add(rating == Ratings.Like);
                parameters.Add(false); //IsCreatorQuickMix
                parameters.Add(song.SongType);

                string xml = GetXml("station.addFeedback", parameters);
                string encryptedXml = EncryptionHelper.EncryptString(xml);
                client.UploadDataAsync(uri, "POST", System.Text.Encoding.ASCII.GetBytes(encryptedXml));
            }
            catch (Exception exception)
            {
                if (ExceptionReceived != null)
                    ExceptionReceived(this, new EventArgs<Exception>(exception));
            }
        }
Пример #15
0
 public void CreateStationFromSong(Song song)
 {
     RunTask(() =>
     {
         Station station = _pandora.CreateStationFromSong(song);
         if (StationCreated != null)
             StationCreated(this, station);
     });
 }
Пример #16
0
        private void PlayedSongAdd(Song song)
        {
            var songControl = new ContentControl();
            RoutedEventHandler loadEvent = AnimateListAdd(lstOldSongs.Items.Count == 0);
            songControl.Loaded += loadEvent;
            songControl.Tag = loadEvent;
            songControl.ContentTemplate = (DataTemplate) Resources["SongTemplate"];
            songControl.Content = song;

            lstOldSongs.Items.Insert(0, songControl);
        }
Пример #17
0
 public void SongBookmarkArtist(Song song)
 {
     if (!IsStationLoaded) return;
     RunTask(song.BookmarkArtist);
 }
Пример #18
0
        private void PlayedSongRemove(Song song)
        {
            ContentControl result = null;
            foreach (ContentControl sc in lstOldSongs.Items)
            {
                if (song == sc.Content)
                {
                    result = sc;
                    break;
                }
            }

            if (result != null)
            {
                bool last = lstOldSongs.Items.IndexOf(result) == (lstOldSongs.Items.Count - 1);
                Dispatcher.Invoke(AnimateListRemove(result, last));
            }
        }
Пример #19
0
 public void SongThumbDown(Song song)
 {
     if (!IsStationLoaded) return;
     RunTask(() => RateSong(song, SongRating.ban));
 }
Пример #20
0
        private void SetSong(Song song)
        {
            CurrentSong.Content = song;
            CurrentSong.Visibility = Visibility.Visible;
            WaitScreen.Visibility = Visibility.Collapsed;

            this.BeginDispatch(() =>
            {
                String[] stat = txtStationName.Text.Split('-');
                if (stat[0].Equals("Quick Mix"))
                {
                    txtStationName.Text = stat[0]+"-"+song.Station.Name;
                }
            });
        }
Пример #21
0
 public void SongTired(Song song)
 {
     if (!IsStationLoaded) return;
     RunTask(song.SetTired);
 }
Пример #22
0
 private void SongMenu_Closed(object sender, RoutedEventArgs e)
 {
     _currMenuSong = null;
 }
Пример #23
0
 private void _pandora_FeedbackUpdateEvent(object sender, Song song, bool success)
 {
     if (FeedbackUpdateEvent != null)
         FeedbackUpdateEvent(this, song, success);
 }
Пример #24
0
        private void _player_FeedbackUpdateEvent(object sender, Song song, bool success)
        {
            this.BeginDispatch(() =>
                                   {
                                       if (_feedbackMap.ContainsKey(song))
                                       {
                                           //bit of a hack, but avoids putting INotify in lower level classes or making wrappers
                                           foreach (ImageButton button in _feedbackMap[song])
                                           {
                                               var spinner = button.FindParent<ContentSpinner>();
                                               BindingExpression bind =
                                                   button.GetBindingExpression(ImageButton.IsActiveProperty);
                                               if (bind != null) bind.UpdateTarget();
                                               spinner.StopAnimation();
                                           }
                                           _feedbackMap.Remove(song);

                                           if (song.Banned && song == _player.CurrentSong) _player.Next();
                                       }
                                   });
        }
Пример #25
0
 private void _playlist_PlayedSongQueued(object sender, Song newSong)
 {
     if (PlayedSongAdded != null)
         PlayedSongAdded(this, newSong);
 }
Пример #26
0
 private void _player_PlayedSongRemoved(object sender, Song song)
 {
     this.BeginDispatch(() => PlayedSongRemove(song));
 }
Пример #27
0
 public Station CreateStationFromArtist(Song song)
 {
     return CreateStation(song, "artist");
 }
Пример #28
0
 private void _player_SongStarted(object sender, Song song)
 {
     lock (_currSongLock)
     {
         _currSong = song;
     }
 }
Пример #29
0
        private Station CreateStation(Song song, string type)
        {
            JObject req = new JObject();
            req["trackToken"] = song.TrackToken;
            req["musicType"] = type;
            var result = CallRPC("station.createStation", req);

            var station = new Station(this, result.Result);
            Stations.Add(station);

            return station;
        }
        private void SubmitFeedback(Song song, Ratings rating)
        {
            WriteLog();

            if (_clientIsBusy)
                return;

            if (!EnsureAuthenticated("SubmitFeedback"))
                return;

            if (song == null)
                return;

            if (rating == Ratings.Dislike)
            {
                CFDialogParams dialogParams = new CFDialogParams();
                dialogParams.displaytext = "Are you sure you want to dislike this song?";
                DialogResult dialogResult = CF_displayDialog(CF_Dialogs.YesNo, dialogParams);

                if (dialogResult != DialogResult.OK)
                    return;
            }

            _clientIsBusy = true;
            _songToRate = song;
            _ratingToSubmit = rating;
            _pandoraClient.SubmitFeedbackAsync(song, rating);
        }