示例#1
0
        public void FillPlaylist(SonosPlayer pl)
        {
            IList <PlaylistItem> list = new List <PlaylistItem>();

            try
            {
                var xml = pl.GetPlaylistWithTotalNumbers(NumberReturned, 0);
                if (xml[0] == null || xml[0].Length == 0)
                {
                    xml = pl.GetPlaylistWithTotalNumbers(NumberReturned, 0, 500);
                }
                if (xml[0] == null || xml[0].Length == 0)
                {
                    SonosHelper.ServerErrorsAdd("Playlist:FillPlaylist:Block1", new Exception("Zurückgelieferte Liste Leer"));
                }

                if (xml[1] != null)
                {
                    TotalMatches = Convert.ToInt16(xml[1]);
                    list         = ParseSonosXML(xml[0]);
                }
            }
            catch (Exception ex)
            {
                SonosHelper.ServerErrorsAdd("Playlist:FillPlaylist:Block1", ex);
            }

            //Eintrag in der Liste vorhanden
            if (TotalMatches == 0 && list.Count == 0)
            {
                PlayListItems.Add(new PlaylistItem()
                {
                    Album = "Leer", Artist = "Leer", Title = "Leer"
                });
                return;
            }
            try
            {
                if (list.Count > 0)
                {
                    PlayListItems.AddRange(list);
                    NumberReturned = Convert.ToUInt16(PlayListItems.Count);
                }

                if (PlayListItems.Count < TotalMatches)
                {
                    FillPlaylist(pl);
                }
            }
            catch (Exception ex)
            {
                SonosHelper.ServerErrorsAdd("Playlist:FillPlaylist:Block2", ex);
            }
        }
示例#2
0
 /// <summary>
 /// Prüft die übergebene Playlist mit dem Übergeben Player ob neu geladen werden muss.
 /// </summary>
 /// <param name="pl">Playliste, die geladen werden soll.</param>
 /// <param name="sp">Coordinator aus der Führenden Zone</param>
 /// <returns>True muss neu geladen werden</returns>
 public static Boolean CheckPlaylist(string pl, SonosPlayer sp)
 {
     try
     {
         Boolean retval     = false;
         var     evtlStream = sp.GetAktSongInfo();
         if (SonosItemHelper.CheckItemForStreamingUriCheck(evtlStream.TrackURI))
         {
             return(true);
         }
         var actpl = sp.GetPlaylist(0, 10);
         if (actpl.Count == 0)
         {
             return(true);
         }
         var toLoadpl = sp.BrowsingWithLimitResults(pl, 10);
         if (toLoadpl.Count == 0)
         {
             return(true);                    //eigentlich ein Fehler
         }
         for (int i = 0; i < actpl.Count; i++)
         {
             if (actpl[i].Title == toLoadpl[i].Title)
             {
                 continue;
             }
             retval = true;
             break;
         }
         return(retval);
     }
     catch (Exception ex)
     {
         SonosHelper.ServerErrorsAdd("Dash2:CheckPlaylist", ex);
         return(true);
     }
 }