Exemplo n.º 1
0
 public VideoTogglePlayPauseCommand(
     HohoemaPlaylistPlayer playlistPlayer,
     MediaPlayer mediaPlayer,
     RestoreNavigationManager restoreNavigationManager)
 {
     _playlistPlayer           = playlistPlayer;
     _mediaPlayer              = mediaPlayer;
     _restoreNavigationManager = restoreNavigationManager;
 }
        /* 複数ウィンドウでプレイヤーを一つだけ表示するための管理をしています
         *
         * 前提としてUnityContainer(PrismUnityApplication App.xaml.cs を参照)による依存性解決を利用しており
         * さらに「PerThreadLifetimeManager」を指定して依存解決時にウィンドウのUIスレッドごとに
         * PlayerViewManagerが生成されるように設定しています。
         *
         * これはObservableObjectによるINofityPropertyChangedイベントがウィンドウスレッドを越えて利用できないことが理由です。
         *
         * PlayerViewManagerはNowPlayingとPlayerViewModeの2つを公開プロパティとして保持しています。
         * NowPlaying
         *
         */

        // プレイヤーの表示状態を管理する
        // これまでHohoemaPlaylist、MenuNavigationViewModelBaseなどに散らばっていた

        public SecondaryViewPlayerManager(
            IScheduler scheduler,
            RestoreNavigationManager restoreNavigationManager
            )
        {
            _scheduler = scheduler;
            _restoreNavigationManager = restoreNavigationManager;
            MainViewId = ApplicationView.GetApplicationViewIdForWindow(CoreApplication.MainView.CoreWindow);
        }
Exemplo n.º 3
0
        public HohoemaPlaylistPlayer(
            IScheduler scheduler,
            IMessenger messenger,
            MediaPlayer mediaPlayer,
            VideoStreamingOriginOrchestrator videoStreamingOriginOrchestrator,
            PlayerSettings playerSettings,
            MediaPlayerSoundVolumeManager soundVolumeManager,
            RestoreNavigationManager restoreNavigationManager
            )
            : base(playerSettings, scheduler)
        {
            _messenger   = messenger;
            _mediaPlayer = mediaPlayer;
            _videoStreamingOriginOrchestrator = videoStreamingOriginOrchestrator;
            _playerSettings           = playerSettings;
            _soundVolumeManager       = soundVolumeManager;
            _restoreNavigationManager = restoreNavigationManager;
            _smtc            = SystemMediaTransportControls.GetForCurrentView();
            _dispatcherQueue = DispatcherQueue.GetForCurrentThread();

            _saveTimer             = _dispatcherQueue.CreateTimer();
            _saveTimer.Interval    = TimeSpan.FromSeconds(5);
            _saveTimer.IsRepeating = true;
            _saveTimer.Tick       += (s, _) =>
            {
                if (CurrentPlaylistItem == null)
                {
                    _saveTimer.Stop();
                    return;
                }

                //if (PrimaryViewPlayerManager.DisplayMode == PrimaryPlayerDisplayMode.Close) { return; }
                if (_mediaPlayer.PlaybackSession?.PlaybackState is not MediaPlaybackState.Playing)
                {
                    return;
                }

                _restoreNavigationManager.SetCurrentPlayerEntry(
                    new PlayerEntry()
                {
                    ContentId      = CurrentPlaylistItem.VideoId,
                    Position       = _mediaPlayer.PlaybackSession.Position,
                    PlaylistId     = CurrentPlaylistId?.Id,
                    PlaylistOrigin = CurrentPlaylistId?.Origin
                });
            };
        }
Exemplo n.º 4
0
        public PrimaryViewPlayerManager(
            ILoggerFactory loggerFactory,
            IScheduler scheduler,
            RestoreNavigationManager restoreNavigationManager,
            HohoemaPlaylistPlayer hohoemaPlaylistPlayer
            )
        {
            _view      = ApplicationView.GetForCurrentView();
            _logger    = loggerFactory.CreateLogger <PrimaryViewPlayerManager>();
            _scheduler = scheduler;
            //_navigationServiceLazy = navigationServiceLazy;
            _restoreNavigationManager = restoreNavigationManager;
            PlaylistPlayer            = hohoemaPlaylistPlayer;
            _navigationService        = null;

            this.ObserveProperty(x => x.DisplayMode, isPushCurrentValueAtFirst: false)
            .Subscribe(x =>
            {
                SetDisplayMode(_prevDisplayMode, x);
                _prevDisplayMode = x;
                IsFullScreen     = x == PrimaryPlayerDisplayMode.FullScreen;
                IsCompactOverlay = x == PrimaryPlayerDisplayMode.CompactOverlay;
            });
        }
        public PrimaryWindowCoreLayoutViewModel(
            [Dependency("PrimaryWindowNavigationService")] Lazy <INavigationService> navigationServiceLazy,
            IEventAggregator eventAggregator,
            IScheduler scheduler,
            ApplicationSettings applicationSettings,
            RestoreNavigationManager restoreNavigationManager,
            SourceStorageItemsRepository sourceStorageItemsRepository,
            PathReferenceCountManager PathReferenceCountManager,
            FolderContainerTypeManager folderContainerTypeManager,
            StorageItemSearchManager storageItemSearchManager,
            SourceChoiceCommand sourceChoiceCommand,
            RefreshNavigationCommand refreshNavigationCommand,
            OpenPageCommand openPageCommand
            )
        {
            MenuItems = new List <object>
            {
                new MenuItemViewModel()
                {
                    PageType = nameof(Views.SourceStorageItemsPage)
                },
                //new MenuItemViewModel() { PageType = nameof(Views.CollectionPage) },
            };
            _navigationServiceLazy              = navigationServiceLazy;
            EventAggregator                     = eventAggregator;
            _scheduler                          = scheduler;
            ApplicationSettings                 = applicationSettings;
            RestoreNavigationManager            = restoreNavigationManager;
            SourceStorageItemsRepository        = sourceStorageItemsRepository;
            _PathReferenceCountManager          = PathReferenceCountManager;
            _folderContainerTypeManager         = folderContainerTypeManager;
            _storageItemSearchManager           = storageItemSearchManager;
            SourceChoiceCommand                 = sourceChoiceCommand;
            SourceChoiceCommand.OpenAfterChoice = true;
            RefreshNavigationCommand            = refreshNavigationCommand;
            OpenPageCommand                     = openPageCommand;


            UpdateAutoSuggestCommand = new ReactiveCommand <string>();

            UpdateAutoSuggestCommand
            .Throttle(TimeSpan.FromSeconds(0.250), _scheduler)
            .Subscribe(ExecuteUpdateAutoSuggestCommand)
            .AddTo(_disposables);

            EventAggregator.GetEvent <PathReferenceCountUpdateWhenSourceManagementChanged.SearchIndexUpdateProgressEvent>()
            .Subscribe(args =>
            {
                _autoSuggestBoxSearchIndexGroup.SearchIndexUpdateProgressCount = args.ProcessedCount;
                _autoSuggestBoxSearchIndexGroup.SearchIndexUpdateTotalCount    = args.TotalCount;

                Debug.WriteLine($"[SearchIndexUpdate] progress: {args.ProcessedCount}/{args.TotalCount} ");
            }
                       , ThreadOption.UIThread
                       , keepSubscriberReferenceAlive: true
                       )
            .AddTo(_disposables);

            AutoSuggestBoxItems = new[]
            {
                _AutoSuggestItemsGroup,
                _autoSuggestBoxSearchIndexGroup
            };
        }
        public PrimaryWindowCoreLayoutViewModel(
            ILoggerFactory loggerFactory,
            NiconicoSession niconicoSession,
            PageManager pageManager,
            PinSettings pinSettings,
            AppearanceSettings appearanceSettings,
            SearchCommand searchCommand,
            DialogService dialogService,
            NotificationService notificationService,
            PrimaryViewPlayerManager primaryViewPlayerManager,
            ObservableMediaPlayer observableMediaPlayer,
            NiconicoLoginService niconicoLoginService,
            LogoutFromNiconicoCommand logoutFromNiconicoCommand,
            WindowService windowService,
            ApplicationLayoutManager applicationLayoutManager,
            RestoreNavigationManager restoreNavigationManager,
            VideoItemsSelectionContext videoItemsSelectionContext,
            QueueMenuItemViewModel queueMenuItemViewModel,
            LoginUserOwnedMylistManager userMylistManager,
            LocalMylistManager localMylistManager,
            OpenLiveContentCommand openLiveContentCommand
            )
        {
            _logger                    = loggerFactory.CreateLogger <PrimaryWindowCoreLayoutViewModel>();
            NiconicoSession            = niconicoSession;
            PageManager                = pageManager;
            PinSettings                = pinSettings;
            AppearanceSettings         = appearanceSettings;
            SearchCommand              = searchCommand;
            _dialogService             = dialogService;
            _notificationService       = notificationService;
            PrimaryViewPlayerManager   = primaryViewPlayerManager;
            ObservableMediaPlayer      = observableMediaPlayer;
            NiconicoLoginService       = niconicoLoginService;
            LogoutFromNiconicoCommand  = logoutFromNiconicoCommand;
            WindowService              = windowService;
            ApplicationLayoutManager   = applicationLayoutManager;
            RestoreNavigationManager   = restoreNavigationManager;
            VideoItemsSelectionContext = videoItemsSelectionContext;

            WeakReferenceMessenger.Default.Register <SettingsRestoredMessage>(this);

            SearchAutoSuggestItems = new ObservableCollection <SearchAutoSuggestItemViewModel>
            {
                new SearchAutoSuggestItemViewModel()
                {
                    Id           = "VideoSearchSuggest",
                    SearchAction = (s) => PageManager.Search(SearchTarget.Keyword, s),
                },
                new SearchAutoSuggestItemViewModel()
                {
                    Id           = "LiveSearchSuggest",
                    SearchAction = (s) => PageManager.Search(SearchTarget.Niconama, s),
                },
                new SearchAutoSuggestItemViewModel()
                {
                    Id           = "DetailSearchSuggest",
                    SearchAction = (s) => PageManager.OpenPage(HohoemaPageType.Search, ""),
                },
            };

            _queueMenuItemViewModel          = queueMenuItemViewModel;
            _userMylistManager               = userMylistManager;
            _localMylistManager              = localMylistManager;
            OpenLiveContentCommand           = openLiveContentCommand;
            _pinsMenuSubItemViewModel        = new PinsMenuSubItemViewModel("Pin".Translate(), PinSettings, _dialogService, _notificationService);
            _localMylistMenuSubItemViewModel = new LocalMylistSubMenuItemViewModel(_localMylistManager, PageManager.OpenPageCommand);

            // メニュー項目の初期化
            MenuItems_LoggedIn = new ObservableCollection <HohoemaListingPageItemBase>()
            {
                _pinsMenuSubItemViewModel,
                _queueMenuItemViewModel,
                new LogginUserLiveSummaryItemViewModel(NiconicoSession, _logger, OpenLiveContentCommand),
                new SeparatorMenuItemViewModel(),
                new MenuItemViewModel(HohoemaPageType.RankingCategoryList.Translate(), HohoemaPageType.RankingCategoryList),
                new MenuItemViewModel(HohoemaPageType.NicoRepo.Translate(), HohoemaPageType.NicoRepo),
                new MenuItemViewModel(HohoemaPageType.WatchHistory.Translate(), HohoemaPageType.WatchHistory),
                new MenuItemViewModel("WatchAfterMylist".Translate(), HohoemaPageType.Mylist, new NavigationParameters(("id", MylistId.WatchAfterMylistId.ToString()))),
                new MylistSubMenuMenu(_userMylistManager, PageManager.OpenPageCommand),
                _localMylistMenuSubItemViewModel,
                new MenuItemViewModel(HohoemaPageType.FollowManage.Translate(), HohoemaPageType.FollowManage),
                new MenuItemViewModel(HohoemaPageType.Timeshift.Translate(), HohoemaPageType.Timeshift),
                new MenuItemViewModel(HohoemaPageType.SubscriptionManagement.Translate(), HohoemaPageType.SubscriptionManagement),
                new MenuItemViewModel(HohoemaPageType.CacheManagement.Translate(), HohoemaPageType.CacheManagement),
            };

            MenuItems_Offline = new ObservableCollection <HohoemaListingPageItemBase>()
            {
                _pinsMenuSubItemViewModel,
                _queueMenuItemViewModel,
                new SeparatorMenuItemViewModel(),
                new MenuItemViewModel(HohoemaPageType.RankingCategoryList.Translate(), HohoemaPageType.RankingCategoryList),
                _localMylistMenuSubItemViewModel,
                new MenuItemViewModel(HohoemaPageType.SubscriptionManagement.Translate(), HohoemaPageType.SubscriptionManagement),
                new MenuItemViewModel(HohoemaPageType.CacheManagement.Translate(), HohoemaPageType.CacheManagement),
            };
        }