Beispiel #1
0
        public PlayerWithPageContainerViewModel(HohoemaApp hohoemaApp, HohoemaPlaylist playlist)
        {
            HohoemaPlaylist = playlist;

            IsFillFloatContent = HohoemaPlaylist
                                 .ObserveProperty(x => x.IsPlayerFloatingModeEnable)
                                 .Select(x => !x)
                                 .ToReadOnlyReactiveProperty();

            IsFillFloatContent_DelayedRead = IsFillFloatContent
                                             .Delay(TimeSpan.FromMilliseconds(300))
                                             .ToReadOnlyReactiveProperty();


            IsVisibleFloatContent = HohoemaPlaylist.ObserveProperty(x => x.IsDisplayMainViewPlayer)
                                    .ToReactiveProperty(mode: ReactivePropertyMode.DistinctUntilChanged);

            IsContentDisplayFloating = Observable.CombineLatest(
                IsFillFloatContent.Select(x => !x),
                IsVisibleFloatContent
                )
                                       .Select(x => x.All(y => y))
                                       .ToReactiveProperty();


            HohoemaPlaylist.OpenPlaylistItem += HohoemaPlaylist_OpenPlaylistItem;

            IsVisibleFloatContent
            .Where(x => !x)
            .Subscribe(x =>
            {
                ClosePlayer();
            });

            if (ApiInformation.IsApiContractPresent("Windows.Foundation.UniversalApiContract", 4))
            {
                Observable.Merge(
                    IsVisibleFloatContent.Where(x => !x),
                    IsContentDisplayFloating.Where(x => x)
                    )
                .Subscribe(async x =>
                {
                    var view = ApplicationView.GetForCurrentView();
                    if (view.IsViewModeSupported(ApplicationViewMode.CompactOverlay))
                    {
                        var result = await view.TryEnterViewModeAsync(ApplicationViewMode.Default);
                    }
                });
            }
        }
Beispiel #2
0
        public VideoPlayer(
            MediaPlayer mediaPlayer,
            IScheduler scheduler,
            HohoemaPlaylist hohoemaPlaylist,
            PlayerSettings playerSettings
            )
        {
            _mediaPlayer = mediaPlayer;
            _scheduler = scheduler;
            _hohoemaPlaylist = hohoemaPlaylist;
            _playerSettings = playerSettings;

            // Playing Video
            IsPlayWithCache = new ReactiveProperty<bool>(_scheduler, false)
                .AddTo(_disposables);


            // Playlist
            PlayNextCommand = _hohoemaPlaylist.ObserveProperty(x => x.CanGoNext)
                .ToReactiveCommand(_scheduler)
                .AddTo(_disposables);
            PlayNextCommand.CanExecuteChangedAsObservable()
                .Subscribe(x => Debug.WriteLine("CanPlayNext changed: " + PlayNextCommand.CanExecute()))
                .AddTo(_disposables);
            PlayNextCommand.Subscribe(PlayNext)
                .AddTo(_disposables);
            PlayPreviousCommand = _hohoemaPlaylist.ObserveProperty(x => x.CanGoBack)
                .ToReactiveCommand(_scheduler)
                .AddTo(_disposables);
            PlayPreviousCommand.Subscribe(PlayPrevious)
                .AddTo(_disposables);

            IsShuffleEnabled = _hohoemaPlaylist.ToReactivePropertyAsSynchronized(x => x.IsShuffleEnabled, _scheduler)
                .AddTo(_disposables);
            IsReverseEnabled = _hohoemaPlaylist.ToReactivePropertyAsSynchronized(x => x.IsReverseEnable, _scheduler)
                .AddTo(_disposables);

            IsCurrentVideoLoopingEnabled = _playerSettings.ToReactivePropertyAsSynchronized(x => x.IsCurrentVideoLoopingEnabled, _scheduler)
                .AddTo(_disposables);

            IsCurrentVideoLoopingEnabled.Subscribe(x =>
            {
                _mediaPlayer.IsLoopingEnabled = x;
            })
                .AddTo(_disposables);

            _mediaPlayer.PlaybackSession.PositionChanged += PlaybackSession_PositionChanged;
        }
        public RelatedVideosSidePaneContentViewModel(
            NicoVideoProvider nicoVideoProvider,
            ChannelProvider channelProvider,
            MylistRepository mylistRepository,
            HohoemaPlaylist hohoemaPlaylist,
            PageManager pageManager,
            IScheduler scheduler
            )
        {
            NicoVideoProvider = nicoVideoProvider;
            ChannelProvider   = channelProvider;
            _mylistRepository = mylistRepository;
            HohoemaPlaylist   = hohoemaPlaylist;
            PageManager       = pageManager;
            _scheduler        = scheduler;

            HasVideoDescription = _VideoViewerHelpInfo != null;

            HohoemaPlaylist.ObserveProperty(x => x.CurrentItem)
            .Subscribe(async item =>
            {
                Clear();
                _IsInitialized = false;

                await Task.Delay(1000);

                if (item != null)
                {
                    await InitializeRelatedVideos(item);
                }
            })
            .AddTo(_CompositeDisposable);
        }
Beispiel #4
0
        public PlayerWithPageContainerViewModel(HohoemaApp hohoemaApp, HohoemaPlaylist playlist)
        {
            HohoemaPlaylist = playlist;

            IsFillFloatContent = HohoemaPlaylist
                                 .ToReactivePropertyAsSynchronized(x =>
                                                                   x.IsPlayerFloatingModeEnable
                                                                   , (x) => !x
                                                                   , (x) => !x
                                                                   );

            IsFillFloatContent_DelayedRead = IsFillFloatContent
                                             .Delay(TimeSpan.FromMilliseconds(300))
                                             .ToReadOnlyReactiveProperty();


            IsVisibleFloatContent = HohoemaPlaylist.ObserveProperty(x => x.IsDisplayPlayer)
                                    .ToReactiveProperty();

            IsContentDisplayFloating = Observable.CombineLatest(
                IsFillFloatContent.Select(x => !x),
                IsVisibleFloatContent
                )
                                       .Select(x => x.All(y => y))
                                       .ToReactiveProperty();

            ContentVM = new ReactiveProperty <ViewModelBase>();


            HohoemaPlaylist.OpenPlaylistItem += HohoemaPlaylist_OpenPlaylistItem;

            IsVisibleFloatContent
            .Where(x => !x)
            .Subscribe(x =>
            {
                ClosePlayer();
            });


            App.Current.Suspending += Current_Suspending;
        }
Beispiel #5
0
        public PlaylistSidePaneContentViewModel(
            MediaPlayer mediaPlayer,
            HohoemaPlaylist playerModel,
            PlayerSettings playerSettings,
            PageManager pageManager,
            IScheduler scheduler
            )
        {
            MediaPlayer     = mediaPlayer;
            HohoemaPlaylist = playerModel;
            _playerSettings = playerSettings;
            PageManager     = pageManager;
            _scheduler      = scheduler;

            CurrentPlaylistName = HohoemaPlaylist.ObserveProperty(x => x.CurrentPlaylist).Select(x => x?.Label)
                                  .ToReadOnlyReactiveProperty(eventScheduler: _scheduler)
                                  .AddTo(_CompositeDisposable);
            IsShuffleEnabled = _playerSettings.ToReactivePropertyAsSynchronized(x => x.IsShuffleEnable, _scheduler)
                               .AddTo(_CompositeDisposable);

            IsListRepeatModeEnable = _playerSettings.ObserveProperty(x => x.IsPlaylistLoopingEnabled)
                                     .ToReactiveProperty(_scheduler)
                                     .AddTo(_CompositeDisposable);

            IsReverseEnabled = _playerSettings.ToReactivePropertyAsSynchronized(x => x.IsReverseModeEnable, _scheduler)
                               .AddTo(_CompositeDisposable);

            PlaylistCanGoBack = HohoemaPlaylist.ObserveProperty(x => x.CanGoBack)
                                .ToReactiveProperty(_scheduler)
                                .AddTo(_CompositeDisposable);
            PlaylistCanGoNext = HohoemaPlaylist.ObserveProperty(x => x.CanGoNext)
                                .ToReactiveProperty(_scheduler)
                                .AddTo(_CompositeDisposable);

            CurrentItems = HohoemaPlaylist.PlaylistItems.ToReadOnlyReactiveCollection(_scheduler)
                           .AddTo(_CompositeDisposable);

            QueueItems = HohoemaPlaylist.QueuePlaylist.ToReadOnlyReactiveCollection(_scheduler)
                         .AddTo(_CompositeDisposable);

            _currentItemCollectionView = new ObservableCollection <IVideoContent>();

            _currentPlaylistViewItem = new PlaylistCollectionViewItem()
            {
                Id    = "playlist",
                Items = CurrentItems
            };

            _playlistCollectionViews = new ObservableCollection <PlaylistCollectionViewItem>()
            {
                new PlaylistCollectionViewItem()
                {
                    Id    = "_current_video_",
                    Label = "PlayingVideo".Translate(),
                    Items = _currentItemCollectionView
                },
                new PlaylistCollectionViewItem()
                {
                    Id    = "@queue",
                    Label = "@queue".Translate(),
                    Items = QueueItems,
                },
                _currentPlaylistViewItem
            };

            HohoemaPlaylist.ObserveProperty(x => x.CurrentPlaylist).Subscribe(x =>
            {
                _currentPlaylistViewItem.Label = x?.Label ?? string.Empty;
            })
            .AddTo(_CompositeDisposable);

            HohoemaPlaylist.ObserveProperty(x => x.CurrentItem)
            .Subscribe(x =>
            {
                _currentItemCollectionView.Clear();
                _currentItemCollectionView.Add(x);
            })
            .AddTo(_CompositeDisposable);

            CollectionViewSource = new CollectionViewSource()
            {
                IsSourceGrouped = true,
                Source          = _playlistCollectionViews,
                ItemsPath       = new Windows.UI.Xaml.PropertyPath(nameof(PlaylistCollectionViewItem.Items))
            };
        }