public async Task InitializeAsync()
        {
            var settingsLoader = new SettingsLoader();

            VideosPerPage = int.Parse((await settingsLoader.GetSettingAsync(Setting.MAXVIDEOSPERPAGE))?.Value ?? "50");
            ThumpnailSize = int.Parse((await settingsLoader.GetSettingAsync(Setting.THUMPNAILSIZE))?.Value ?? "320");

            var videos = await _VideoProvider.GetVideos();

            videos = videos.OrderBy(x => x.Artist.Name).ThenBy(x => x.Name).ToList();
            foreach (var video in videos)
            {
                var vidVM = new VideoViewModel(video);
                Videos.Add(vidVM);
            }

            FilteredVideos = Videos.ToList();

            // Add all videos to CurrentPageVideos, page filtering is done via SourceCollectionView.Filter
            foreach (var video in Videos)
            {
                CurrentPageVideos.Add(video);
            }

            VideoCollectionView.MoveCurrentToFirst();

            MaxPage = Videos.Count / VideosPerPage;

            GroupAfterArtist(null);

            foreach (var video in Videos)
            {
                video.ThumbailBitmap = await video.GetThumbnailBitmap().ConfigureAwait(false);
            }
        }
Beispiel #2
0
            public static async Task <string> GetVideos(string Source, string Keyword, int PageNo, int PageSize, Dictionary <string, object> AdditionalData)
            {
                string CacheKey = CacheFactory.GetCacheKey(CacheFactory.Keys.Videos, Source, Keyword, PageNo, PageSize);
                string Videos   = CacheFactory.Get(CacheKey);

                if (Videos == null)
                {
                    IVideoProvider provider = GetAvailableProviders().Where(p => p.Name == Source).FirstOrDefault();
                    if (provider == null)
                    {
                        return(Videos);
                    }

                    Videos = await provider.GetVideos(Keyword, PageNo, PageSize, AdditionalData);

                    CacheFactory.Set(CacheKey, Videos);
                }
                return(Videos);
            }