Example #1
0
        private void RestorePlayer()
        {
            var viewModel = DataContext as VideoPageViewModel;

            if (viewModel == null)
            {
                return;
            }

            //новый
            player = new LiteTubePlayer
            {
                IsFullScreenVisible         = true,
                IsFullScreenEnabled         = true,
                VerticalAlignment           = VerticalAlignment.Center,
                IsSkipAheadVisible          = true,
                IsSkipBackVisible           = true,
                SkipAheadInterval           = TimeSpan.FromSeconds(10),
                SkipBackInterval            = TimeSpan.FromSeconds(10),
                AllowMediaStartingDeferrals = false,
                AutoPlay                 = _autoPlay,
                VideoTitle               = viewModel.Title,
                ChannelTitle             = viewModel.ChannelTitle,
                RelatedItems             = viewModel.RelatedVideosViewModel.Items,
                ItemClickCommand         = viewModel.RelatedVideosViewModel.ItemClickCommand,
                LoadMoreCommand          = viewModel.RelatedVideosViewModel.LoadMoreCommand,
                VideoQualityItems        = viewModel.VideoQualities,
                SelectedVideoQualityItem = viewModel.SelectedVideoQualityItem,
                IsLive      = viewModel.IsLive,
                DataContext = DataContext
            };

            var binding = new Binding {
                Source = viewModel, Path = new PropertyPath("VideoUri")
            };

            player.SetBinding(LiteTubePlayer.SourceProperty, binding);

            var binding1 = new Binding {
                Source = viewModel, Path = new PropertyPath("SelectedVideoQualityItem"), Mode = BindingMode.TwoWay
            };

            player.SetBinding(LiteTubePlayer.SelectedVideoQualityItemProperty, binding1);

            SubscribePlayerEvents(player);

            if (_playerState != null)
            {
                player.RestoreMediaState(_playerState);
            }

            var oldPlayer = playerBg.Children.FirstOrDefault(x => x is LiteTubePlayer);

            if (oldPlayer != null)
            {
                playerBg.Children.Remove(oldPlayer);
            }

            playerBg.Children.Add(player);

            if (_isFullScreen)
            {
                SetPlayerFullScreenState();
            }
            else
            {
                SetPlayerNormalState();
            }
        }
Example #2
0
        private void RestorePlayer()
        {
            var viewModel = DataContext as PlaylistVideoPageViewModel;

            if (viewModel == null)
            {
                return;
            }

            //новый
            player = new LiteTubePlayer
            {
                Name = "player",
                IsFullScreenVisible         = true,
                IsFullScreenEnabled         = true,
                VerticalAlignment           = VerticalAlignment.Center,
                IsSkipAheadVisible          = true,
                IsSkipBackVisible           = true,
                SkipAheadInterval           = TimeSpan.FromSeconds(10),
                SkipBackInterval            = TimeSpan.FromSeconds(10),
                IsSkipNextVisible           = true,
                IsSkipPreviousVisible       = true,
                AllowMediaStartingDeferrals = false,
                AutoPlay = _autoPlay,
                Position = TimeSpan.FromSeconds(0),
                IsLive   = viewModel.VideoViewModel.IsLive
            };

            var binding = new Binding {
                Source = viewModel, Path = new PropertyPath("VideoViewModel.VideoUri")
            };

            player.SetBinding(LiteTubePlayer.SourceProperty, binding);

            binding = new Binding {
                Source = viewModel, Path = new PropertyPath("VideoViewModel.Title")
            };
            player.SetBinding(LiteTubePlayer.VideoTitleProperty, binding);

            binding = new Binding {
                Source = viewModel, Path = new PropertyPath("VideoViewModel.ChannelTitle")
            };
            player.SetBinding(LiteTubePlayer.ChannelTitleProperty, binding);

            binding = new Binding {
                Source = viewModel, Path = new PropertyPath("PlaylistVideosViewModel.Items")
            };
            player.SetBinding(LiteTubePlayer.RelatedItemsProperty, binding);

            binding = new Binding {
                Source = viewModel, Path = new PropertyPath("PlaylistVideosViewModel.ItemClickCommand")
            };
            player.SetBinding(LiteTubePlayer.ItemClickCommandProperty, binding);

            binding = new Binding {
                Source = viewModel, Path = new PropertyPath("PlaylistVideosViewModel.LoadMoreCommand")
            };
            player.SetBinding(LiteTubePlayer.LoadMoreCommandProperty, binding);

            binding = new Binding {
                Source = viewModel, Path = new PropertyPath("VideoViewModel.ImagePath")
            };
            player.SetBinding(LiteTubePlayer.PosterSourceProperty, binding);

            binding = new Binding {
                Source = viewModel, Path = new PropertyPath("VideoViewModel.VideoQualities")
            };
            player.SetBinding(LiteTubePlayer.VideoQualityItemsProperty, binding);

            var binding1 = new Binding {
                Source = viewModel, Path = new PropertyPath("VideoViewModel.SelectedVideoQualityItem"), Mode = BindingMode.TwoWay
            };

            player.SetBinding(LiteTubePlayer.SelectedVideoQualityItemProperty, binding1);

            playerBg.Children.Clear();
            playerBg.Children.Add(player);

            SubscribePlayerEvents(player);
            player.RestoreMediaState(_playerState);

            if (_isFullScreen)
            {
                SetPlayerFullScreenState();
            }
            else
            {
                SetPlayerNormalState();
            }
        }