public bool TuneIntoTags(List <String> tags_)
        {
            string TuneTags = String.Empty;

            foreach (string singleTag in tags_)
            {
                TuneTags += AudioscrobblerBase.getValidURLLastFMString(singleTag) + ",";
            }
            // remove trailing comma
            TuneTags = TuneTags.Remove(TuneTags.Length - 1);

            if (
                SendCommandRequest(@"http://ws.audioscrobbler.com/radio/adjust.php?session=" + _currentSession +
                                   @"&url=lastfm://globaltags/" + TuneTags))
            {
                _currentTuneType = StreamType.Tag;
                Log.Info("StreamControl: Tune into tags: {0}", TuneTags);
                // GUIPropertyManager.SetProperty("#Play.Current.Lastfm.CurrentStream", GUILocalizeStrings.Get(34041) + TuneTags);
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemple #2
0
        public string GetTransmitInfo(out int num_tracks)
        {
            StringBuilder sb = new StringBuilder();

            int i;

            for (i = 0; i < queue.Count; i++)
            {
                /* we queue a maximum of 10 tracks per request */
                if (i == 9)
                {
                    break;
                }

                QueuedTrack track = (QueuedTrack)queue[i];

                //s=<sessionID>
                //a[0]=<artist>
                //t[0]=<track>
                //i[0]=<time>
                //o[0]=<source>
                //r[0]=<rating>
                //l[0]=<secs>
                //b[0]=<album>
                //n[0]=<tracknumber>
                //m[0}=<mb-trackid>

                string trackNr = track.TrackNr > 0 ? Convert.ToString(track.TrackNr) : String.Empty;

                sb.AppendFormat(
                    "&a[{0}]={1}&t[{0}]={2}&i[{0}]={3}&o[{0}]={4}&r[{0}]={5}&l[{0}]={6}&b[{0}]={7}&n[{0}]={8}&m[{0}]={9}",
                    i,                                                                                             // number of queued items = 0
                    AudioscrobblerBase.getValidURLLastFMString(AudioscrobblerBase.UndoArtistPrefix(track.Artist)), // artist = 1
                    HttpUtility.UrlEncode(track.Title),                                                            // track = 2
                    track.StartTime,                                                                               // time = 3
                    track.Source,                                                                                  // source = 4
                    track.Rating,                                                                                  // rating = 5
                    track.Duration.ToString(),                                                                     // secs = 6
                    AudioscrobblerBase.getValidURLLastFMString(track.Album),                                       // album = 7
                    trackNr,                                                                                       // tracknumber = 8
                    String.Empty                                                                                   // The MusicBrainz Track ID, or empty if not known.
                    );
            }

            num_tracks = i;
            return(sb.ToString());
        }
        public bool TuneIntoWebPlaylist(string username_)
        {
            string TuneUser = AudioscrobblerBase.getValidURLLastFMString(username_);

            if (
                SendCommandRequest(@"http://ws.audioscrobbler.com/radio/adjust.php?session=" + _currentSession +
                                   @"&url=lastfm://user/" + TuneUser + "/playlist"))
            {
                _currentTuneType = StreamType.Playlist;
                Log.Info("StreamControl: Tune into web playlist of: {0}", username_);
                // GUIPropertyManager.SetProperty("#Play.Current.Lastfm.CurrentStream", GUILocalizeStrings.Get(34049));
                return(true);
            }
            else
            {
                return(false);
            }
        }
        public bool TuneIntoGroupRadio(string groupname_)
        {
            string TuneGroup = AudioscrobblerBase.getValidURLLastFMString(groupname_);

            if (
                SendCommandRequest(@"http://ws.audioscrobbler.com/radio/adjust.php?session=" + _currentSession +
                                   @"&url=lastfm://group/" + TuneGroup))
            {
                _currentTuneType = StreamType.Group;
                Log.Info("StreamControl: Tune into group radio for: {0}", groupname_);

                // GUIPropertyManager.SetProperty("#Play.Current.Lastfm.CurrentStream", "Group radio of: " + groupname_);

                return(true);
            }
            else
            {
                return(false);
            }
        }
        public bool TuneIntoArtists(List <String> artists_)
        {
            string TuneArtists = String.Empty;

            foreach (string singleArtist in artists_)
            {
                TuneArtists += AudioscrobblerBase.getValidURLLastFMString(singleArtist) + ",";
            }
            // remove trailing comma
            TuneArtists = TuneArtists.Remove(TuneArtists.Length - 1);
            if (
                SendCommandRequest(@"http://ws.audioscrobbler.com/radio/adjust.php?session=" + _currentSession +
                                   @"&url=lastfm://artist/" + TuneArtists + "/similarartists&lang=de"))
            {
                _currentTuneType = StreamType.Artist;
                Log.Info("StreamControl: Tune into artists similar to: {0}", TuneArtists);
                // GUIPropertyManager.SetProperty("#Play.Current.Lastfm.CurrentStream", "Artists similar to: " + TuneArtists);
                return(true);
            }
            else
            {
                return(false);
            }
        }