コード例 #1
0
ファイル: Xbmc.AudioPlayer.cs プロジェクト: GroupXTech/Yatse2
 public void PlaySong(ApiAudioSong audio)
 {
     if (audio == null)
         return;
     if (!_parent.IsConnected())
         return;
     _parent.Command("PlayFile(" + audio.Path + audio.FileName + ";0)");
 }
コード例 #2
0
ファイル: Xbmc.AudioPlayer.cs プロジェクト: Ghawken/FrontView
 public void PlaySong(ApiAudioSong audio)
 {
     if (audio == null)
         return;
     if (!_parent.IsConnected())
         return;
     var args = new JsonObject();
     args["songid"] = audio.IdSong;
     _parent.AsyncJsonCommand("XBMC.Play", args);
 }
コード例 #3
0
ファイル: Xbmc.AudioPlayer.cs プロジェクト: GroupXTech/Yatse2
 public void PlaySong(ApiAudioSong audio)
 {
     if (audio == null)
         return;
     if (!_parent.IsConnected())
         return;
     var args = new JsonObject();
     var items = new JsonObject();
     args["songid"] = audio.IdSong;
     items["item"] = args;
     items["playlistid"] = 1;
     var plId = new JsonObject();
     plId["playlistid"] = 1;
     var item = new JsonObject();
     item["item"] = plId;
     _parent.JsonCommand("Playlist.Clear", plId);
     _parent.JsonCommand("Playlist.Add", items);
     _parent.JsonCommand("Playlist.Play", item);
 }
コード例 #4
0
        public Collection<ApiAudioSong> GetSongs()
        {
            var songs = new Collection<ApiAudioSong>();
            const string req = "SELECT idSong,strTitle,iTrack,iDuration,iYear,strFileName,idAlbum,strAlbum,strPath,idArtist,strArtist,idGenre,strGenre,strThumb FROM songview";


            var dblines = _parent.DBCommand("music", req);
            if (dblines == null) return songs;
            foreach (var dbline in dblines)
            {
                if (dbline.Length < 14)
                {
                    _parent.Log("Invalid request DATA : " + dbline);
                    continue;
                }
                var song = new ApiAudioSong
                {
                    IdSong = Xbmc.StringToNumber(dbline[0]),
                    Title = dbline[1],
                    Track = Xbmc.StringToNumber(dbline[2]),
                    Duration = Xbmc.StringToNumber(dbline[3]),
                    Year = Xbmc.StringToNumber(dbline[4]),
                    FileName = dbline[5],
                    IdAlbum = Xbmc.StringToNumber(dbline[6]),
                    Album = dbline[7],
                    Path = dbline[8],
                    IdArtist = Xbmc.StringToNumber(dbline[9]),
                    Artist = dbline[10],
                    IdGenre = Xbmc.StringToNumber(dbline[11]),
                    Genre = dbline[12],
                    Thumb = dbline[13],
                };
                var thumbparts = dbline[13].Split('/');
                var hash = thumbparts[thumbparts.Length - 1].Replace(".tbn", "");
                song.Hash = hash;

                songs.Add(song);
            }
            return songs;
        }
コード例 #5
0
ファイル: Xbmc.AudioPlayer.cs プロジェクト: Ghawken/FrontView
        public void PlaySong(ApiAudioSong audio)
        {
            if (audio == null)
                return;
            if (!_parent.IsConnected())
                return;

            EmbyPlayPlayList(audio.Path);

        }
コード例 #6
0
    public Collection<ApiAudioSong> GetSongs()
    {
      var songs = new Collection<ApiAudioSong>();

      var properties = new JsonArray(new[] { "title", "thumbnail", "genre", "genreid", "artist", "year", "duration", "album", "albumid", "track" });
      var param = new JsonObject();
      param["properties"] = properties;
      var result = (JsonObject)_parent.JsonCommand("AudioLibrary.GetSongs", param);
      if (result != null)
      {
        if (result.Contains("songs"))
        {
          foreach (JsonObject genre in (JsonArray)result["songs"])
          {
            try
            {
              var song = new ApiAudioSong
                {
                  IdSong = (long)(JsonNumber)genre["songid"],
                  Title = genre["title"].ToString(),
                  Track = (long)(JsonNumber)genre["track"],
                  Duration = (long)(JsonNumber)genre["duration"],
                  Year = (long)(JsonNumber)genre["year"],
                  FileName = "",
                  IdAlbum = (long)(JsonNumber)genre["albumid"],
                  Album = genre["album"].ToString(),
                  Path = "",
                  IdArtist = 0,
                  Artist = _parent.JsonArrayToString((JsonArray)genre["artist"]),
                  IdGenre = 0,
                  Genre = _parent.JsonArrayToString((JsonArray)genre["genre"]),
                  Thumb = genre["thumbnail"].ToString(),
                };
              songs.Add(song);
            }
            catch (Exception)
            {
            }
          }
        }
      }

      return songs;
    }
コード例 #7
0
        public Collection<ApiAudioSong> GetSongs()
        {
            var songs = new Collection<ApiAudioSong>();
           // var MusicID = GetMainSelection("Songs");


            try
            {
                _parent.Trace("Getting Songs: Parent IP: " + _parent.IP);
                string NPurl = "http://" + _parent.IP + ":" + _parent.Port + "/emby/Users/" + Globals.CurrentUserID + "/Items?Recursive=true&IncludeItemTypes=Audio&EnableImages=true"; 
                var request = WebRequest.CreateHttp(NPurl);
                request.Method = "get";
                request.Timeout = 150000;
                _parent.Trace("Songs Selection: " + NPurl);
                var authString = _parent.GetAuthString();
                request.Headers.Add("X-MediaBrowser-Token", Globals.EmbyAuthToken);
                request.Headers.Add("X-Emby-Authorization", authString);
                request.ContentType = "application/json; charset=utf-8";
                request.Accept = "application/json; charset=utf-8";

                var response = request.GetResponse();

                if (((HttpWebResponse)response).StatusCode == HttpStatusCode.OK)
                {

                    System.IO.Stream dataStream = response.GetResponseStream();


                    using (var sr = new System.IO.StreamReader(response.GetResponseStream()))
                    {
                        string json = sr.ReadToEnd();
                        _parent.Trace("--------------GETTING Songs Selection Result ------" + json);

                        var deserializer = new JavaScriptSerializer();
                        deserializer.MaxJsonLength = Int32.MaxValue;
                        long GenreIDSet = 0;
                        var ItemData = deserializer.Deserialize<MusicSongs.Rootobject>(json);
                        MusicGenres.Rootobject MusicGenres = GetMusicGenres();

                        foreach (var genre in ItemData.Items)
                        {
                           
                            // Do get more data - but takes FOREVER !!
                            MusicSongSingleItem.Rootobject Songitem = GetSingleSong(genre.Id);
                            
                            foreach (var findingid in MusicGenres.Items)
                            {
                                if (Songitem.Genres != null && Songitem.Genres.Length != 0)
                                {
                                if ( findingid.Name == Songitem.Genres.FirstOrDefault().ToString() )
                                {
                                    GenreIDSet = Xbmc.IDtoNumber(findingid.Id);
                                }
                                }

                            }

                            var RoundSeconds = (genre.RunTimeTicks / 10000000.00) ?? 0;

                            string TempSongGenreID = "";
                            if (genre.AlbumArtists != null && genre.AlbumArtists.Length != 0)
                            {
                                if (genre.AlbumArtists.FirstOrDefault() != null)
                                {
                                    TempSongGenreID = genre.AlbumArtists.FirstOrDefault().Id;
                                }
                            }

                            string TempSongGenre = "";
                            if (Songitem.Genres != null && Songitem.Genres.Length != 0)
                            {
                                if (Songitem.Genres.FirstOrDefault() != null)
                                {
                                    TempSongGenre = Songitem.Genres.FirstOrDefault().ToString();
                                }
                            }


                            try
                            {
                                 var song = new ApiAudioSong
                                 {
                                     IdSong = Xbmc.IDtoNumber(genre.Id),
                                     Title = genre.Name ?? "",
                                     Track = Convert.ToInt64(genre.IndexNumber ?? 0),
                                     Duration = Convert.ToInt64(RoundSeconds),
                                     Year = Convert.ToInt64(genre.ProductionYear ?? 1999),
                                     FileName = Songitem.Path,
                                     IdAlbum = Xbmc.IDtoNumber(genre.AlbumId),
                                     Album = genre.Album ?? "",
                                     Path = genre.Id,
                                     IdArtist = Xbmc.IDtoNumber(TempSongGenreID),
                                     Artist = genre.Artists.FirstOrDefault() ?? "",
                                     IdGenre = GenreIDSet,
                                     Genre = TempSongGenre ?? "",
                                     Thumb = "http://" + _parent.IP + ":" + _parent.Port + "/Items/" + genre.Id + "/Images/Primary" ?? "",
                                 };
                                songs.Add(song);
                            }
                            catch (Exception)
                            {
                            }
                        }
                    }
                }

            return songs;
            }


            catch (Exception ex)
            {
                _parent.Trace("Exception Caught: " + ex);
                return null;
            }

        }
コード例 #8
0
        public Collection<ApiAudioSong> GetSongs()
        {
            var songs = new Collection<ApiAudioSong>();
            if (!_parent.IsConnected())
                return songs;
            var dblines = _parent.IPimpDBCommand(new CommandInfoIPimp { Action = "getallmusicsongs" }, "songs");
            if (dblines == null) return songs;

            foreach (JsonObject dbline in dblines)
            {
                var song = new ApiAudioSong
                {
                    IdAlbum = Convert.ToInt32("0" + (string)dbline["id"], CultureInfo.InvariantCulture),
                    Thumb = (string)dbline["thumb"],
                    Fanart = (string)dbline["fanart"],
                    IdGenre = 0,
                    Artist = (string)dbline["albumartist"],
                    Genre = (string)dbline["genre"],
                    Title = (string)dbline["song"],
                    Year = Convert.ToInt32("0" + (string)dbline["year"], CultureInfo.InvariantCulture),
                    Hash = MediaPortal.Hash((string)dbline["song"]),
                    Album = (string)dbline["album"],
                    Duration = Convert.ToInt32("0" + (string)dbline["duration"], CultureInfo.InvariantCulture),
                    FileName = (string)dbline["filename"],
                    Track = Convert.ToInt32("0" + (string)dbline["tracknumber"], CultureInfo.InvariantCulture),
                    IdArtist = 0,
                    IdSong = Convert.ToInt32("0" + (string)dbline["id"], CultureInfo.InvariantCulture),
                    Path = ""
                };

                songs.Add(song);
            }

            return songs;
        }
コード例 #9
0
 public void PlaySong(ApiAudioSong audio)
 {
     
 }
コード例 #10
0
ファイル: Yatse2Media.cs プロジェクト: Ghawken/FrontView
 public Yatse2AudioSong(ApiAudioSong apiAudioSong)
 {
     if (apiAudioSong == null)
         return;
     Title = apiAudioSong.Title;
     IdAlbum = apiAudioSong.IdAlbum;
     IdArtist = apiAudioSong.IdArtist;
     Artist = apiAudioSong.Artist;
     Genre = apiAudioSong.Genre;
     IdGenre = apiAudioSong.IdGenre;
     Year = apiAudioSong.Year;
     Thumb = apiAudioSong.Thumb;
     Fanart = apiAudioSong.Fanart;
     Hash = apiAudioSong.Hash;
     Album = apiAudioSong.Album;
     Duration = apiAudioSong.Duration;
     FileName = apiAudioSong.FileName;
     IdSong = apiAudioSong.IdSong;
     Path = apiAudioSong.Path;
     Track = apiAudioSong.Track;
 }
コード例 #11
0
ファイル: Yatse2Media.cs プロジェクト: Ghawken/FrontView
        public ApiAudioSong ToApi()
        {
            var api = new ApiAudioSong
                          {
                            Album = Album,
                            Artist = Artist,
                            Duration = Duration,
                            Fanart = Fanart,
                            Hash = Hash,
                            IdArtist = IdArtist,
                            Thumb = Thumb,
                            FileName = FileName,
                            Genre = Genre,
                            IdAlbum = IdAlbum,
                            IdGenre = IdGenre,
                            IdSong = IdSong,
                            Path = Path,
                            Title = Title,
                            Track = Track,
                            Year = Year
            };
            return api;

        }