Ejemplo n.º 1
0
 public void AddtoSelectedPlaylist(IEnumerable <string> collection)
 {
     foreach (string item in collection)
     {
         try
         {
             Uri uri = new Uri(item);
             SelectedPlayList.AddLast(uri);
         }
         catch (Exception e)
         {
             Helpers.ConsoleLogger.Error($"Error while open file {item}: {e.GetType().Name} - {e.Message}");
         }
     }
 }
        private async void GetCategoryPlayList()
        {
            this._OffsetCancellationToken?.Cancel();
            var newCancel = new CancellationTokenSource();

            this._OffsetCancellationToken = newCancel;
            if (string.IsNullOrEmpty(SelectedTag))
            {
                SelectedTag = "全部";
            }
            try
            {
                if (MorePage)
                {
                    var netWorkDataResult = await this._netWorkServices.GetAsync <KeyValuePair <bool, Global.Model.PlayList[]> >("FindMusic", "GetTopPlayListByTag",
                                                                                                                                 new
                    {
                        cat    = SelectedTag,
                        hot    = true,
                        limit  = LimitPerPage,
                        offset = CurrentPlayListPageOffset * LimitPerPage
                    });

                    if (netWorkDataResult.Successed)
                    {
                        var temp = netWorkDataResult.Data;
                        MorePage = temp.Key;
                        SelectedPlayList.AddRange(temp.Value);
                        CurrentPlayListPageOffset++;
                    }
                    else
                    {
                        //todo 显示网络提示信息
                    }
                }
            }
            catch (OperationCanceledException)
            {
            }
            if (this._OffsetCancellationToken == newCancel)
            {
                this._OffsetCancellationToken = null;
            }
        }