예제 #1
0
        private void LoadDataVideo()
        {
            try
            {
                if (Video == null)
                {
                    return;
                }

                if (!string.IsNullOrEmpty(Video.Iframe))
                {
                    TabVideosAbout.LoadVideo_Data(Video);

                    if (Video.Iframe.Contains("Youtube") || Video.Iframe.Contains("youtu"))
                    {
                        var ft = SupportFragmentManager.BeginTransaction();

                        VideoIdYoutube = Video.Iframe.Split(new[] { "v=", "/" }, StringSplitOptions.None).LastOrDefault();

                        YouTubePlayerView youTubeView = new YouTubePlayerView(this);

                        var youtubeView = FindViewById <FrameLayout>(Resource.Id.root);
                        youtubeView.RemoveAllViews();
                        youtubeView.AddView(youTubeView);

                        youTubeView.Initialize(AppSettings.YoutubeKey, this);

                        VideoActionsController.SimpleExoPlayerView.Visibility = ViewStates.Gone;
                        VideoActionsController.ReleaseVideo();

                        YoutubePlayer?.LoadVideo(VideoIdYoutube);
                    }
                }
                else
                {
                    var dbDatabase = new SqLiteDatabase();
                    var dataVideos = dbDatabase.Get_WatchOfflineVideos_ById(Video.Id);
                    if (dataVideos != null)
                    {
                        VideoActionsController.PlayVideo(dataVideos.Source, dataVideos);
                    }
                    else
                    {
                        VideoActionsController.PlayVideo(Video.Source, Video);
                    }
                }
            }
            catch (Exception e)
            {
                Methods.DisplayReportResultTrack(e);
            }
        }
        private void LoadDataVideo()
        {
            try
            {
                if (Video == null)
                {
                    return;
                }

                if (!string.IsNullOrEmpty(Video.Iframe))
                {
                    TabVideosAbout.LoadVideo_Data(Video);

                    if (Video.Iframe.Contains("Youtube") || Video.Iframe.Contains("youtu"))
                    {
                        var ft = SupportFragmentManager.BeginTransaction();

                        VideoIdYoutube = Video.Iframe.Split(new[] { "v=", "/" }, StringSplitOptions.None).LastOrDefault();

                        if (YouTubeFragment == null)
                        {
                            YouTubeFragment = new YouTubePlayerSupportFragment();
                            YouTubeFragment.Initialize(AppSettings.YoutubeKey, this);
                            ft.Add(Resource.Id.root, YouTubeFragment, YouTubeFragment.Id.ToString() + DateTime.Now).Commit();

                            VideoActionsController.SimpleExoPlayerView.Visibility = ViewStates.Gone;
                            VideoActionsController.ReleaseVideo();
                        }
                        else
                        {
                            VideoActionsController.SimpleExoPlayerView.Visibility = ViewStates.Gone;
                            VideoActionsController.ReleaseVideo();

                            if (YouTubeFragment.IsAdded)
                            {
                                ft.Show(YouTubeFragment).Commit();
                            }
                            else
                            {
                                YouTubeFragment = new YouTubePlayerSupportFragment();
                                ft.Add(Resource.Id.root, YouTubeFragment, YouTubeFragment.Id.ToString() + DateTime.Now).Commit();
                            }
                            YouTubeFragment.View.Visibility = ViewStates.Visible;
                            YoutubePlayer?.LoadVideo(VideoIdYoutube);
                        }
                    }
                }
                else
                {
                    var dbDatabase = new SqLiteDatabase();
                    var dataVideos = dbDatabase.Get_WatchOfflineVideos_ById(Video.Id);
                    if (dataVideos != null)
                    {
                        VideoActionsController.PlayVideo(dataVideos.Source, dataVideos);
                    }
                    else
                    {
                        VideoActionsController.PlayVideo(Video.Source, Video);
                    }
                    dbDatabase.Dispose();
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }