Beispiel #1
0
        void UpdateEpisodes()
        {
            var bgColor = Settings.ItemBackGroundColor.ToHex();

            MyEpisodeResultCollection.Clear();
            try {
                var header = Download.downloadHeaders[currentId];
                var helper = Download.downloadHelper[currentId];
                // App.GetDownloadHeaderInfo(currentId);
                List <EpisodeResult> activeEpisodes = new List <EpisodeResult>();

                foreach (var key in helper.infoIds)
                {
                    var info = App.GetDownloadInfo(key);                    //Download.downloads[key];
                    if (info != null)
                    {
                        Download.downloads[key] = info;
                        if (info.state.totalBytes == 0 && info.state.bytesDownloaded != 1)
                        {
                            Download.RemoveDownloadCookie(key);
                        }
                        else
                        {
                            int ep = info.info.episode;
                            int ss = info.info.season;

                            string fileUrl  = info.info.fileUrl;
                            string fileName = info.info.name;

                            int dloaded = (int)info.state.ProcentageDownloaded;
                            // string extra = (info.state.state == App.DownloadState.Downloaded ? "" : App.ConvertBytesToAny(info.state.bytesDownloaded, 0, 2) + " MB of " + App.ConvertBytesToAny(info.state.totalBytes, 0, 2) + " MB");
                            string extra = $" {dloaded }%";
                            //.TapCom = new Command(async (s) => {
                            long   pos;
                            long   len;
                            double _progress = 0;
                            if ((pos = App.GetViewPos(info.info.id)) > 0)
                            {
                                if ((len = App.GetViewDur(info.info.id)) > 0)
                                {
                                    _progress = (double)pos / (double)len;
                                }
                            }
                            var dPlaySource = App.GetImageSource("nexflixPlayBtt.png");

                            activeEpisodes.Add(new EpisodeResult()
                            {
                                OgTitle          = info.info.name,
                                ExtraColor       = bgColor,
                                ExtraDescription = $"{Download.GetExtraString(info.state.state)}{((info.state.state == App.DownloadState.Downloaded || dloaded == -1) ? "" : extra)}",
                                Title            = (ep != -1 ? $"S{ss}:E{ep} " : "") + info.info.name,
                                Description      = info.info.description,
                                Episode          = ep,
                                Season           = ss,
                                Id        = info.info.id,
                                PosterUrl = info.info.hdPosterUrl,
                                Progress  = _progress,
                                TapCom    = new Command(async(s) => {
                                    if (info.info.dtype == App.DownloadType.Normal)
                                    {
                                        MovieResult.SetEpisode("tt" + info.info.id);
                                    }
                                    if (MainChrome.IsConnectedToChromeDevice)
                                    {
                                        await Download.ChromeCastDownloadedFile(info.info.id);
                                    }
                                    else
                                    {
                                        Download.PlayDownloadedFile(info);
                                    }

                                    //Download.PlayDownloadedFile(fileUrl, fileName, info.info.episode, info.info.season, info.info.episodeIMDBId, info.info.source);
                                    // Download.PlayVLCFile(fileUrl, fileName, info.info.id.ToString());
                                }),
                                DownloadPlayBttSource = dPlaySource
                            });
                        }
                    }
                }

                activeEpisodes = activeEpisodes.OrderBy(t => (t.Episode + t.Season * 1000)).ToList();
                for (int i = 0; i < activeEpisodes.Count; i++)
                {
                    int _id = i;
                    activeEpisodes[i].TapComThree = new Command(async() => {
                        await HandleEpisode(MyEpisodeResultCollection[_id]);
                    });
                    MyEpisodeResultCollection.Add(activeEpisodes[i]);
                }

                episodeView.FadeTo(1, 200, Easing.SinOut);
            }
            catch (Exception _ex) {
                print("EXUpdateDEpisodes::: " + _ex);
            }
            SetHeight();

            if (MyEpisodeResultCollection.Count == 0)
            {
                Navigation.PopModalAsync();
            }
        }