Esempio n. 1
0
        private ICollection <XbmcSong> getSongs(int albumId, int artistId, int genreId, int start, int end, params string[] fields)
        {
            this.client.LogMessage("XbmcAudioLibrary.GetSongs()");

            JObject args = new JObject();

            if (albumId >= 0)
            {
                args.Add(new JProperty("albumid", albumId));
            }
            if (artistId >= 0)
            {
                args.Add(new JProperty("artistid", artistId));
            }
            if (genreId >= 0)
            {
                args.Add(new JProperty("genreid", genreId));
            }
            if (fields != null && fields.Length > 0)
            {
                string[] fieldCopy = new string[fields.Length + 3];
                fieldCopy[0] = "title";
                fieldCopy[1] = "artist";
                fieldCopy[2] = "album";
                Array.Copy(fields, 0, fieldCopy, 3, fields.Length);
                args.Add(new JProperty("fields", fieldCopy));
            }
            else
            {
                args.Add(new JProperty("fields", XbmcSong.Fields));
            }
            if (start >= 0)
            {
                args.Add(new JProperty("start", start));
            }
            if (end >= 0)
            {
                args.Add(new JProperty("end", end));
            }

            JObject query = this.client.Call("AudioLibrary.GetSongs", args) as JObject;

            if (query == null || query["songs"] == null)
            {
                this.client.LogErrorMessage("AudioLibrary.GetSongs(): Invalid response");

                return(null);
            }

            List <XbmcSong> songs = new List <XbmcSong>();

            foreach (JObject item in (JArray)query["songs"])
            {
                songs.Add(XbmcSong.FromJson(item, this.client));
            }

            return(songs);
        }
Esempio n. 2
0
        public bool Play(XbmcSong song)
        {
            this.client.LogMessage("XbmcGeneral.Play(song)");

            if (song == null)
            {
                throw new ArgumentNullException("song");
            }
            if (song.Id < 0)
            {
                throw new ArgumentException("Invalid song ID");
            }

            JObject args = new JObject();

            args.Add(new JProperty("songid", song.Id));

            return(this.client.Call("XBMC.Play", args) != null);
        }
Esempio n. 3
0
        private static List<string> buildMusicInfo(ICollection<string> patterns, XbmcSong song)
        {
            Dictionary<string, string> data = new Dictionary<string, string>(10);
            data.Add("title", song.Title);
            data.Add("artist", song.Artist);
            data.Add("album", song.Album);
            data.Add("track", song.Track.ToString());
            data.Add("year", song.Year.ToString());
            data.Add("rating", song.Rating.ToString("0.#"));
            data.Add("genre", song.Genre);
            data.Add("duration", song.Duration.Minutes.ToString("0") + ":" + song.Duration.Seconds.ToString("00"));
            //data.Add("disc", song.Disc.ToString());
            data.Add("lyrics", song.Lyrics);

            return buildInfoText(patterns, data);
        }
        public bool Play(XbmcSong song)
        {
            this.client.LogMessage("XbmcGeneral.Play(song)");

            if (song == null)
            {
                throw new ArgumentNullException("song");
            }
            if (song.Id < 0)
            {
                throw new ArgumentException("Invalid song ID");
            }

            JObject args = new JObject();
            args.Add(new JProperty("songid", song.Id));

            return (this.client.Call("XBMC.Play", args) != null);
        }