Ejemplo n.º 1
0
        async void OnSelectionChanged(object sender, SelectionChangedEventArgs args)
        {
            if (args.CurrentSelection.Count != 1)
            {
                return;
            }
            if (!(args.CurrentSelection[0] is YoutubeExplode.Models.Video vidItem))
            {
                return;
            }
            SearchCollectionView.SelectedItem = null;
            var captions = await viewModel.GetCaptions(vidItem.Id);

            if (captions.Count <= 0)
            {
                await DisplayAlert("Captions", $"No Captions Available for \"{vidItem.Title}\"!", "Dang!");

                return;
            }
            ClosedCaptionTrackInfo info;

            if (captions.Count == 1)
            {
                info = captions.First();
            }
            else
            {
                var capList = captions.Select(n => n.Language.Name).ToArray();
                var action  = await DisplayActionSheet("Pick Caption Language: ", "Cancel", null, capList);

                info = captions.FirstOrDefault(n => n.Language.Name == action);
                if (info == null)
                {
                    return;
                }
            }
            var captionPage = new CaptionsPage(vidItem.Title, vidItem.Id, info);
            await Navigation.PushAsync(captionPage);

            await captionPage.GetCaptionsAsync();
        }
Ejemplo n.º 2
0
        async void OnSelectionChanged(object sender, SelectionChangedEventArgs args)
        {
            // TODO: Temp workaround
            if (args.CurrentSelection.Count != 1)
            {
                return;
            }
            var item = args.CurrentSelection.FirstOrDefault() as PlaylistItem;

            if (item == null)
            {
                return;
            }
            var caption = await viewModel.TempGetCaptions(item);

            var captionPage = new CaptionsPage(item.Snippet.Title, item.Snippet.ResourceId.VideoId, caption);
            await Navigation.PushAsync(captionPage);

            await captionPage.GetCaptionsAsync();

            VideoCollectionView.SelectedItem = null;
        }