Пример #1
0
        public async void DownloadButtonClick()
        {
            List <Playlist> playlistsToBeDownloaded = new List <Playlist>();

            foreach (PlaylistViewModel playVM in playlistsSelected)
            {
                if (playVM.PlaylistModel.clips.Count == 0)
                {
                    ClipResponse response = await ServiceAccessor.GetPlaylistClipsAndHeaders(playVM.PlaylistModel.playlistId);

                    playVM.PlaylistModel.clips          = response.clips;
                    playVM.PlaylistModel.displayColumns = response.DisplayColumns;
                }
                List <Clip> additionalClips = await ServiceAccessor.GetAdditionalPlaylistClips(playVM.PlaylistModel.playlistId, playVM.PlaylistModel.clips.Count);

                foreach (Clip c in additionalClips)
                {
                    playVM.PlaylistModel.clips.Add(c);
                }
                playlistsToBeDownloaded.Add(playVM.PlaylistModel);
            }
            DownloadButton_Visibility     = Visibility.Collapsed;
            Downloading_Visibility        = Visibility.Visible;
            DownloadProgressText          = "Preparing Download";
            DownloadProgress              = 0;
            DownloadAccessor.Instance.cts = new CancellationTokenSource();
            DownloadAccessor.Instance.currentlyDownloadingPlaylists = playlistsToBeDownloaded;
            DownloadAccessor.Instance.progressCallback = new Progress <DownloadOperation>(ProgressCallback);
            DownloadAccessor.Instance.DownloadPlaylists(playlistsToBeDownloaded, Season.DeepCopy(Parameter.season));
        }
Пример #2
0
        public async Task AddClipsAndHeadersForPlaylist(Playlist playlist)
        {
            if (ServiceAccessor.ConnectedToInternet())
            {
                playlist.clips = new BindableCollection <Clip>();
                ClipResponse response = await ServiceAccessor.GetPlaylistClipsAndHeaders(playlist.playlistId);

                if (response.status == SERVICE_RESPONSE.SUCCESS)
                {
                    playlist.clips          = response.clips;
                    playlist.displayColumns = response.DisplayColumns;
                }
                else
                {
                }
            }
        }
Пример #3
0
        public async void GameSelected(ItemClickEventArgs eventArgs)
        {
            PageIsEnabled          = false;
            ProgressRingIsActive   = true;
            ProgressRingVisibility = Visibility.Visible;

            GameViewModel gameViewModel = (GameViewModel)eventArgs.ClickedItem;
            Season        seasonToPass  = new Season()
            {
                name = selectedSeason.name, owningTeam = selectedSeason.owningTeam, seasonId = selectedSeason.seasonId, year = selectedSeason.year, games = new BindableCollection <Game>()
            };                                                                                                                                                                                                               //Because we're changing the games in this season, we need to make a copy.

            seasonToPass.games.Add(gameViewModel.GameModel);

            if (!gameViewModel.IsLastViewed)
            {
                try
                {
                    await gameViewModel.FetchPlaylists;
                    navigationService.NavigateToViewModel <SectionViewModel>(new PageParameter {
                        season = seasonToPass, hubGroups = Groups, playlist = new Playlist()
                    });

                    if (gameViewModel.IsNextGame)
                    {
                        Logger.Instance.LogGameSelected(gameViewModel.GameModel, Logger.LOG_GAME_NEXT);
                    }
                    else if (gameViewModel.IsPreviousGame)
                    {
                        Logger.Instance.LogGameSelected(gameViewModel.GameModel, Logger.LOG_GAME_PREVIOUS);
                    }
                    else
                    {
                        Logger.Instance.LogGameSelected(gameViewModel.GameModel);
                    }
                }
                catch
                {
                    navigationService.NavigateToViewModel <ErrorViewModel>();
                }
            }
            else
            {
                Playlist downloadedPlaylist = DownloadAccessor.Instance.downloadedPlaylists.Where(u => u.playlistId == gameViewModel.GameModel.gameId).FirstOrDefault();
                if (downloadedPlaylist != null)
                {
                    navigationService.NavigateToViewModel <VideoPlayerViewModel>(new PageParameter {
                        season = seasonToPass, hubGroups = Groups, playlist = downloadedPlaylist
                    });
                    Logger.Instance.LogLastViewedClick(downloadedPlaylist);
                }
                else
                {
                    ClipResponse response = await ServiceAccessor.GetPlaylistClipsAndHeaders(gameViewModel.GameModel.gameId);

                    Playlist lastViewedPlaylist = new Playlist {
                        playlistId = gameViewModel.GameModel.gameId, name = gameViewModel.GameModel.opponent, thumbnailLocation = gameViewModel.Thumbnail, clips = response.clips, displayColumns = response.DisplayColumns, clipCount = response.clips.Count
                    };
                    navigationService.NavigateToViewModel <VideoPlayerViewModel>(new PageParameter {
                        season = seasonToPass, hubGroups = Groups, playlist = lastViewedPlaylist
                    });
                    Logger.Instance.LogLastViewedClick(lastViewedPlaylist);
                }
            }
        }