Beispiel #1
0
        public LocalPlaylistPageViewModel(
            ILoggerFactory loggerFactory,
            IMessenger messenger,
            ApplicationLayoutManager applicationLayoutManager,
            PageManager pageManager,
            LocalMylistManager localMylistManager,
            NicoVideoProvider nicoVideoProvider,
            VideoPlayWithQueueCommand videoPlayWithQueueCommand,
            PlaylistPlayAllCommand playlistPlayAllCommand,
            LocalPlaylistDeleteCommand localPlaylistDeleteCommand,
            SelectionModeToggleCommand selectionModeToggleCommand
            )
            : base(loggerFactory.CreateLogger <LocalPlaylistPageViewModel>())
        {
            ApplicationLayoutManager   = applicationLayoutManager;
            _pageManager               = pageManager;
            _localMylistManager        = localMylistManager;
            _nicoVideoProvider         = nicoVideoProvider;
            LocalPlaylistDeleteCommand = localPlaylistDeleteCommand;
            VideoPlayWithQueueCommand  = videoPlayWithQueueCommand;
            PlaylistPlayAllCommand     = playlistPlayAllCommand;
            SelectionModeToggleCommand = selectionModeToggleCommand;
            _messenger = messenger;

            CurrentPlaylistToken = Observable.CombineLatest(
                this.ObserveProperty(x => x.Playlist),
                this.ObserveProperty(x => x.SelectedSortOptionItem),
                (x, y) => new PlaylistToken(x, y)
                )
                                   .ToReadOnlyReactivePropertySlim()
                                   .AddTo(_CompositeDisposable);
        }
Beispiel #2
0
        protected override async void Execute(object parameter)
        {
            var currentMethod = System.Reflection.MethodBase.GetCurrentMethod();
            //Microsoft.AppCenter.Analytics.Analytics.TrackEvent($"{currentMethod.DeclaringType.Name}#{currentMethod.Name}");

            var result = await DialogService.GetTextAsync(
                "LocalPlaylistCreate".Translate(),
                "LocalPlaylistNameTextBoxPlacefolder".Translate(),
                "",
                (s) => !string.IsNullOrWhiteSpace(s)
                );

            if (result != null)
            {
                var localPlaylist = LocalMylistManager.CreatePlaylist(result);

                Debug.WriteLine("ローカルマイリスト作成:" + result);

                if (parameter is IVideoContent content)
                {
                    localPlaylist.AddPlaylistItem(content);
                }
                else if (parameter is string itemId)
                {
                    throw new NotSupportedException();
                }
            }
        }
        public VideoMenuSubPageContent(
            NiconicoSession niconicoSession,
            LocalMylistManager localMylistManager,
            LoginUserOwnedMylistManager mylistManager,
            PageManager pageManager
            )
        {
            NiconicoSession    = niconicoSession;
            LocalMylistManager = localMylistManager;
            MylistManager      = mylistManager;
            PageManager        = pageManager;
            MenuItems          = new ObservableCollection <HohoemaListingPageItemBase>();

            ResetMenuItems();

            LocalMylists = LocalMylistManager.LocalPlaylists
                           .ToReadOnlyReactiveCollection(x =>
                                                         new MenuItemViewModel(x.Name, HohoemaPageType.LocalPlaylist, new NavigationParameters {
                { "id", x.PlaylistId.Id }
            }) as HohoemaListingPageItemBase
                                                         )
                           .AddTo(_CompositeDisposable);
            Mylists = MylistManager.Mylists
                      .ToReadOnlyReactiveCollection(x =>
                                                    new MenuItemViewModel(x.Name, HohoemaPageType.Mylist, new NavigationParameters {
                { "id", x.MylistId }
            }) as HohoemaListingPageItemBase
                                                    )
                      .AddTo(_CompositeDisposable);

            NiconicoSession.LogIn  += OnLogIn;
            NiconicoSession.LogOut += OnLogOut;
        }
Beispiel #4
0
        protected override async void Execute(object parameter)
        {
            var result = await DialogService.GetTextAsync(
                "LocalPlaylistCreate".Translate(),
                "LocalPlaylistNameTextBoxPlacefolder".Translate(),
                "",
                (s) => !string.IsNullOrWhiteSpace(s)
                );

            if (result != null)
            {
                var localMylist   = new Models.LocalMylist.LocalMylistGroup(Guid.NewGuid().ToString(), result);
                var localPlaylist = LocalMylistManager.CreatePlaylist(result);

                Debug.WriteLine("ローカルマイリスト作成:" + result);

                if (parameter is Interfaces.IVideoContent content)
                {
                    localPlaylist.AddPlaylistItem(content);
                }
                else if (parameter is string itemId)
                {
                    throw new NotSupportedException();
                }
            }
        }
Beispiel #5
0
 public DialogService(
     UserMylistManager userMylistManager,
     LocalMylistManager localMylistManager
     )
 {
     UserMylistManager  = userMylistManager;
     LocalMylistManager = localMylistManager;
 }
Beispiel #6
0
 public LocalPlaylistCreateCommand(
     LocalMylistManager localMylistManager,
     DialogService dialogService
     )
 {
     LocalMylistManager = localMylistManager;
     DialogService      = dialogService;
 }
Beispiel #7
0
 public LocalPlaylistDeleteCommand(
     LocalMylistManager localMylistManager,
     DialogService dialogService
     )
 {
     _localMylistManager = localMylistManager;
     _dialogService      = dialogService;
 }
 public LocalMylistPlaylistFactory(
     LocalMylistManager localMylistManager,
     QueuePlaylist queuePlaylist
     )
 {
     _localMylistManager = localMylistManager;
     _queuePlaylist      = queuePlaylist;
 }
Beispiel #9
0
 public PlaylistSelectDialogService(
     DialogService dialogService,
     LoginUserOwnedMylistManager userMylistManager,
     LocalMylistManager localMylistManager
     )
 {
     _dialogService      = dialogService;
     _userMylistManager  = userMylistManager;
     _localMylistManager = localMylistManager;
 }
Beispiel #10
0
 public AddMylistCommand(
     NotificationService notificationService,
     UseCase.Playlist.PlaylistSelectDialogService playlistSelectDialogService,
     LocalMylistManager localMylistManager,
     UserMylistManager userMylistManager
     )
 {
     NotificationService          = notificationService;
     _playlistSelectDialogService = playlistSelectDialogService;
     _localMylistManager          = localMylistManager;
     _userMylistManager           = userMylistManager;
 }
 public MultiSelectSubscriptionDestinationCommand(
     DialogService dialogService,
     LocalMylistManager localMylistManager,
     UserMylistManager userMylistManager,
     HohoemaPlaylist hohoemaPlaylist,
     PlaylistAggregateGetter playlistAggregateGetter
     )
 {
     DialogService            = dialogService;
     LocalMylistManager       = localMylistManager;
     UserMylistManager        = userMylistManager;
     HohoemaPlaylist          = hohoemaPlaylist;
     _playlistAggregateGetter = playlistAggregateGetter;
 }
Beispiel #12
0
 public MultiSelectSubscriptionDestinationCommand(
     DialogService dialogService,
     LocalMylistManager localMylistManager,
     UserMylistManager userMylistManager,
     Services.HohoemaPlaylist hohoemaPlaylist,
     MylistHelper mylistHelper
     )
 {
     DialogService      = dialogService;
     LocalMylistManager = localMylistManager;
     UserMylistManager  = userMylistManager;
     HohoemaPlaylist    = hohoemaPlaylist;
     MylistHelper       = mylistHelper;
 }
Beispiel #13
0
        public NotificationMylistUpdatedService(
            NiconicoSession niconicoSession,
            Models.UserMylistManager userMylistManager,
            LocalMylistManager localMylistManager,
            NotificationService notificationService
            )
        {
            NiconicoSession     = niconicoSession;
            UserMylistManager   = userMylistManager;
            LocalMylistManager  = localMylistManager;
            NotificationService = notificationService;

            Reset();
        }
        public LocalPlaylistManagePageViewModel(
            PageManager pageManager,
            Services.DialogService dialogService,
            ApplicationLayoutManager applicationLayoutManager,
            LocalMylistManager localMylistManager,
            PlaylistPlayAllCommand playlistPlayAllCommand,
            LocalPlaylistCreateCommand localPlaylistCreateCommand,
            LocalPlaylistDeleteCommand localPlaylistDeleteCommand
            )
        {
            _pageManager               = pageManager;
            ApplicationLayoutManager   = applicationLayoutManager;
            _localMylistManager        = localMylistManager;
            PlaylistPlayAllCommand     = playlistPlayAllCommand;
            CreateLocalMylistCommand   = localPlaylistCreateCommand;
            DeleteLocalPlaylistCommand = localPlaylistDeleteCommand;
            ItemsView = new AdvancedCollectionView(_localMylistManager.LocalPlaylists);

            OpenMylistCommand = new ReactiveCommand <IPlaylist>()
                                .AddTo(_CompositeDisposable);

            OpenMylistCommand.Subscribe(listItem =>
            {
                _pageManager.OpenPageWithId(HohoemaPageType.LocalPlaylist, listItem.PlaylistId.Id);
            });


            RenameLocalPlaylistCommand = new RelayCommand <LocalPlaylist>(async playlist =>
            {
                var result = await dialogService.GetTextAsync(
                    "RenameLocalPlaylist",
                    "RenameLocalPlaylist_Placeholder",
                    playlist.Name,
                    name => !string.IsNullOrWhiteSpace(name)
                    );

                if (result is not null)
                {
                    playlist.Name = result;
                }
            });
        }
 public LocalPlaylistPageViewModel(
     ApplicationLayoutManager applicationLayoutManager,
     PageManager pageManager,
     LocalMylistManager localMylistManager,
     HohoemaPlaylist hohoemaPlaylist,
     PlaylistAggregateGetter playlistAggregate,
     LocalPlaylistDeleteCommand localPlaylistDeleteCommand,
     PlaylistPlayAllCommand playlistPlayAllCommand,
     RemoveWatchedItemsInAfterWatchPlaylistCommand removeWatchedItemsInAfterWatchPlaylistCommand
     )
 {
     ApplicationLayoutManager = applicationLayoutManager;
     _pageManager = pageManager;
     _localMylistManager = localMylistManager;
     HohoemaPlaylist = hohoemaPlaylist;
     _playlistAggregate = playlistAggregate;
     LocalPlaylistDeleteCommand = localPlaylistDeleteCommand;
     PlaylistPlayAllCommand = playlistPlayAllCommand;
     RemoveWatchedItemsInAfterWatchPlaylistCommand = removeWatchedItemsInAfterWatchPlaylistCommand;
 }
Beispiel #16
0
 public UserMylistPageViewModel(
     ILoggerFactory loggerFactory,
     ApplicationLayoutManager applicationLayoutManager,
     PageManager pageManager,
     Services.DialogService dialogService,
     NiconicoSession niconicoSession,
     UserProvider userProvider,
     MylistResolver mylistRepository,
     LocalMylistManager localMylistManager
     )
     : base(loggerFactory.CreateLogger <UserMylistPageViewModel>())
 {
     ApplicationLayoutManager = applicationLayoutManager;
     PageManager         = pageManager;
     DialogService       = dialogService;
     NiconicoSession     = niconicoSession;
     UserProvider        = userProvider;
     _mylistRepository   = mylistRepository;
     _localMylistManager = localMylistManager;
 }
        public LocalMylistSubMenuItemViewModel(LocalMylistManager localMylistManager, ICommand openLocalPlaylistManageCommand)
        {
            Label = "LocalPlaylist".Translate();

            _dispatcherQueue               = DispatcherQueue.GetForCurrentThread();
            _localMylistManager            = localMylistManager;
            OpenLocalPlaylistManageCommand = openLocalPlaylistManageCommand;
            _localMylistManager.LocalPlaylists.CollectionChangedAsObservable()
            .Subscribe(e =>
            {
                _dispatcherQueue.TryEnqueue(() =>
                {
                    if (e.Action == System.Collections.Specialized.NotifyCollectionChangedAction.Remove)
                    {
                        var items = e.OldItems.Cast <LocalPlaylist>();
                        foreach (var removedItem in items)
                        {
                            var removeMenuItem = Items.FirstOrDefault(x => (x as LocalMylistItemViewModel).LocalPlaylist.PlaylistId == removedItem.PlaylistId);
                            if (removeMenuItem != null)
                            {
                                Items.Remove(removeMenuItem);
                            }
                        }
                    }
                    else if (e.Action == System.Collections.Specialized.NotifyCollectionChangedAction.Add)
                    {
                        var items = e.NewItems.Cast <LocalPlaylist>();
                        foreach (var item in items)
                        {
                            Items.Add(new LocalMylistItemViewModel(item));
                        }
                    }
                    else if (e.Action == System.Collections.Specialized.NotifyCollectionChangedAction.Reset)
                    {
                        Items.Clear();
                    }
                });
            });

            Items = new ObservableCollection <MenuItemViewModel>(_localMylistManager.LocalPlaylists.Select(x => new LocalMylistItemViewModel(x)));
        }
        public VideoItemsListView()
        {
            this.InitializeComponent();

            // Selection
            _selectionContext     = Microsoft.Toolkit.Mvvm.DependencyInjection.Ioc.Default.GetService <VideoItemsSelectionContext>();
            _niconicoSession      = Microsoft.Toolkit.Mvvm.DependencyInjection.Ioc.Default.GetService <NiconicoSession>();
            _localPlaylistManager = Microsoft.Toolkit.Mvvm.DependencyInjection.Ioc.Default.GetService <LocalMylistManager>();
            _mylistManager        = Microsoft.Toolkit.Mvvm.DependencyInjection.Ioc.Default.GetService <LoginUserOwnedMylistManager>();
            _queuePlaylist        = Microsoft.Toolkit.Mvvm.DependencyInjection.Ioc.Default.GetService <QueuePlaylist>();

            _addQueueCommand           = Microsoft.Toolkit.Mvvm.DependencyInjection.Ioc.Default.GetService <QueueAddItemCommand>();
            _removeQueueCommand        = Microsoft.Toolkit.Mvvm.DependencyInjection.Ioc.Default.GetService <QueueRemoveItemCommand>();
            _addMylistCommand          = Microsoft.Toolkit.Mvvm.DependencyInjection.Ioc.Default.GetService <MylistAddItemCommand>();
            _localMylistAddCommand     = new LocalPlaylistAddItemCommand();
            _removeWatchHistoryCommand = Microsoft.Toolkit.Mvvm.DependencyInjection.Ioc.Default.GetService <WatchHistoryRemoveItemCommand>();
            _copyMylistItemCommand     = Microsoft.Toolkit.Mvvm.DependencyInjection.Ioc.Default.GetService <MylistCopyItemCommand>();
            _moveMylistItemCommand     = Microsoft.Toolkit.Mvvm.DependencyInjection.Ioc.Default.GetService <MylistMoveItemCommand>();

            Loaded   += VideoItemsListView_Loaded;
            Unloaded += VideoItemsListView_Unloaded;
        }
Beispiel #19
0
        public VideoPlayerPageViewModel(
            IScheduler scheduler,
            IEventAggregator eventAggregator,
            Models.NiconicoSession niconicoSession,
            Models.Subscription.SubscriptionManager subscriptionManager,
            NicoVideoProvider nicoVideoProvider,
            ChannelProvider channelProvider,
            MylistProvider mylistProvider,
            PlayerSettings playerSettings,
            CacheSettings cacheSettings,
            NGSettings ngSettings,
            ApplicationLayoutManager applicationLayoutManager,
            HohoemaPlaylist hohoemaPlaylist,
            LocalMylistManager localMylistManager,
            UserMylistManager userMylistManager,
            PageManager pageManager,
            MediaPlayer mediaPlayer,
            NotificationService notificationService,
            DialogService dialogService,
            ExternalAccessService externalAccessService,
            Commands.Subscriptions.CreateSubscriptionGroupCommand createSubscriptionGroupCommand,
            Commands.Mylist.CreateLocalMylistCommand createLocalMylistCommand,
            Commands.Mylist.CreateMylistCommand createMylistCommand,
            UseCase.NicoVideoPlayer.VideoStreamingOriginOrchestrator videoStreamingOriginOrchestrator,
            UseCase.VideoPlayer videoPlayer,
            UseCase.CommentPlayer commentPlayer,
            KeepActiveDisplayWhenPlaying keepActiveDisplayWhenPlaying,
            ObservableMediaPlayer observableMediaPlayer,
            WindowService windowService,
            VideoEndedRecommendation videoEndedRecommendation,
            PrimaryViewPlayerManager primaryViewPlayerManager,
            TogglePlayerDisplayViewCommand togglePlayerDisplayViewCommand,
            ShowPrimaryViewCommand showPrimaryViewCommand,
            MediaPlayerSoundVolumeManager soundVolumeManager
            )
        {
            _scheduler                        = scheduler;
            NiconicoSession                   = niconicoSession;
            SubscriptionManager               = subscriptionManager;
            NicoVideoProvider                 = nicoVideoProvider;
            ChannelProvider                   = channelProvider;
            MylistProvider                    = mylistProvider;
            PlayerSettings                    = playerSettings;
            CacheSettings                     = cacheSettings;
            NgSettings                        = ngSettings;
            ApplicationLayoutManager          = applicationLayoutManager;
            HohoemaPlaylist                   = hohoemaPlaylist;
            LocalMylistManager                = localMylistManager;
            UserMylistManager                 = userMylistManager;
            PageManager                       = pageManager;
            _NotificationService              = notificationService;
            _HohoemaDialogService             = dialogService;
            ExternalAccessService             = externalAccessService;
            CreateSubscriptionGroupCommand    = createSubscriptionGroupCommand;
            CreateLocalMylistCommand          = createLocalMylistCommand;
            CreateMylistCommand               = createMylistCommand;
            _videoStreamingOriginOrchestrator = videoStreamingOriginOrchestrator;
            VideoPlayer                       = videoPlayer;
            CommentPlayer                     = commentPlayer;
            PrimaryViewPlayerManager          = primaryViewPlayerManager;
            TogglePlayerDisplayViewCommand    = togglePlayerDisplayViewCommand;
            ShowPrimaryViewCommand            = showPrimaryViewCommand;
            SoundVolumeManager                = soundVolumeManager;
            ObservableMediaPlayer             = observableMediaPlayer
                                                .AddTo(_CompositeDisposable);
            WindowService = windowService
                            .AddTo(_CompositeDisposable);
            VideoEndedRecommendation = videoEndedRecommendation
                                       .AddTo(_CompositeDisposable);
            _keepActiveDisplayWhenPlaying = keepActiveDisplayWhenPlaying
                                            .AddTo(_CompositeDisposable);
            MediaPlayer = mediaPlayer;

            SeekCommand            = new MediaPlayerSeekCommand(MediaPlayer);
            SetPlaybackRateCommand = new MediaPlayerSetPlaybackRateCommand(MediaPlayer);
            ToggleMuteCommand      = new MediaPlayerToggleMuteCommand(MediaPlayer);
            VolumeUpCommand        = new MediaPlayerVolumeUpCommand(SoundVolumeManager);
            VolumeDownCommand      = new MediaPlayerVolumeDownCommand(SoundVolumeManager);
        }
 public LocalMylistCreateCommand(LocalMylistManager localMylistManager)
 {
     _localMylistManager = localMylistManager;
 }
        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),
            };
        }
Beispiel #22
0
        private async Task EnsureInitializeAsync()
        {
            using (await InitializeLock.LockAsync())
            {
                if (isInitialized)
                {
                    return;
                }
                isInitialized = true;

                var settings = await Models.HohoemaUserSettings.LoadSettings(ApplicationData.Current.LocalFolder);

                var unityContainer = Container.GetContainer();
                unityContainer.RegisterInstance(settings.ActivityFeedSettings);
                unityContainer.RegisterInstance(settings.AppearanceSettings);
                unityContainer.RegisterInstance(settings.CacheSettings);
                unityContainer.RegisterInstance(settings.NGSettings);
                unityContainer.RegisterInstance(settings.PinSettings);
                unityContainer.RegisterInstance(settings.PlayerSettings);
                unityContainer.RegisterInstance(settings.PlaylistSettings);
                unityContainer.RegisterInstance(settings.RankingSettings);

                // ログイン前にログインセッションによって状態が変化するフォローとマイリストの初期化
                var followManager = Container.Resolve <FollowManager>();
                var mylitManager  = Container.Resolve <UserMylistManager>();

                var localMylistManager = Container.Resolve <LocalMylistManager>();
                await LocalMylistManager.RestoreLegacyLocalMylistGroups(localMylistManager);

                Resources["IsXbox"]   = Services.Helpers.DeviceTypeHelper.IsXbox;
                Resources["IsMobile"] = Services.Helpers.DeviceTypeHelper.IsMobile;


                try
                {
#if DEBUG
                    if (_DEBUG_XBOX_RESOURCE)
#else
                    if (Services.Helpers.DeviceTypeHelper.IsXbox)
#endif
                    {
                        this.Resources.MergedDictionaries.Add(new ResourceDictionary()
                        {
                            Source = new Uri("ms-appx:///Styles/TVSafeColor.xaml")
                        });
                        this.Resources.MergedDictionaries.Add(new ResourceDictionary()
                        {
                            Source = new Uri("ms-appx:///Styles/TVStyle.xaml")
                        });
                    }
                }
                catch
                {
                }



#if DEBUG
                Resources["IsDebug"] = true;
#else
                Resources["IsDebug"] = false;
#endif
                Resources["TitleBarCustomized"]  = IsTitleBarCustomized;
                Resources["TitleBarDummyHeight"] = IsTitleBarCustomized ? 32.0 : 0.0;


                if (IsTitleBarCustomized)
                {
                    var coreApp = CoreApplication.GetCurrentView();
                    coreApp.TitleBar.ExtendViewIntoTitleBar = true;

                    var appView = ApplicationView.GetForCurrentView();
                    appView.TitleBar.ButtonBackgroundColor         = Colors.Transparent;
                    appView.TitleBar.ButtonInactiveBackgroundColor = Colors.Transparent;

                    if (RequestedTheme == ApplicationTheme.Light)
                    {
                        appView.TitleBar.ButtonForegroundColor         = Colors.Black;
                        appView.TitleBar.ButtonHoverBackgroundColor    = Colors.DarkGray;
                        appView.TitleBar.ButtonHoverForegroundColor    = Colors.Black;
                        appView.TitleBar.ButtonInactiveForegroundColor = Colors.Gray;
                    }
                    else
                    {
                        appView.TitleBar.ButtonForegroundColor         = Colors.White;
                        appView.TitleBar.ButtonHoverBackgroundColor    = Colors.DimGray;
                        appView.TitleBar.ButtonHoverForegroundColor    = Colors.White;
                        appView.TitleBar.ButtonInactiveForegroundColor = Colors.DarkGray;
                    }
                }

                //
                var cacheSettings = Container.Resolve <CacheSettings>();
                Resources["IsCacheEnabled"] = cacheSettings.IsEnableCache;
                var appearanceSettings = Container.Resolve <AppearanceSettings>();
                Resources["IsTVModeEnabled"] = Services.Helpers.DeviceTypeHelper.IsXbox || appearanceSettings.IsForceTVModeEnable;

                var layout = CreateShell(out var frame);
                var ns     = Prism.Navigation.NavigationService.Create(frame, Window.Current.CoreWindow, /*Gesture.Back, */ Gesture.Forward, Gesture.Refresh);

                Container.GetContainer().RegisterInstance(ns);

                Window.Current.Content = layout;

                // ウィンドウサイズの保存と復元
                if (Services.Helpers.DeviceTypeHelper.IsDesktop)
                {
                    var localObjectStorageHelper = Container.Resolve <Microsoft.Toolkit.Uwp.Helpers.LocalObjectStorageHelper>();
                    if (localObjectStorageHelper.KeyExists(PlayerViewManager.primary_view_size))
                    {
                        var view = ApplicationView.GetForCurrentView();
                        MainViewId      = view.Id;
                        _PrevWindowSize = localObjectStorageHelper.Read <Size>(PlayerViewManager.primary_view_size);
                        view.TryResizeView(_PrevWindowSize);
                        ApplicationView.PreferredLaunchWindowingMode = ApplicationViewWindowingMode.Auto;
                    }
                }

                // XboxOneで外枠表示を行わないように設定
                if (Services.Helpers.DeviceTypeHelper.IsXbox)
                {
                    Windows.UI.ViewManagement.ApplicationView.GetForCurrentView().SetDesiredBoundsMode
                        (Windows.UI.ViewManagement.ApplicationViewBoundsMode.UseCoreWindow);
                }

                // モバイルでナビゲーションバーをアプリに被せないように設定
                if (Services.Helpers.DeviceTypeHelper.IsMobile)
                {
                    // モバイルで利用している場合に、ナビゲーションバーなどがページに被さらないように指定
                    ApplicationView.GetForCurrentView().SuppressSystemOverlays = true;
                    ApplicationView.GetForCurrentView().SetDesiredBoundsMode(ApplicationViewBoundsMode.UseVisible);
                }



                // 2段階認証を処理するログインサービスをインスタンス化
                var loginService = Container.Resolve <NiconicoLoginService>();



                // 更新通知を表示
                try
                {
                    var dialogService = Container.Resolve <Services.DialogService>();
                    if (Models.Helpers.AppUpdateNotice.HasNotCheckedUptedeNoticeVersion)
                    {
                        _ = dialogService.ShowLatestUpdateNotice();
                        Models.Helpers.AppUpdateNotice.UpdateLastCheckedVersionInCurrentVersion();
                    }
                }
                catch { }


                // アプリのユースケース系サービスを配置
                unityContainer.RegisterInstance(unityContainer.Resolve <Services.WatchItLater>());
                unityContainer.RegisterInstance(unityContainer.Resolve <Services.Notification.NotificationCacheVideoDeletedService>());
                unityContainer.RegisterInstance(unityContainer.Resolve <Services.Notification.NotificationMylistUpdatedService>());
                unityContainer.RegisterInstance(unityContainer.Resolve <Services.Page.PreventBackNavigationOnShowPlayerService>());
                unityContainer.RegisterInstance(unityContainer.Resolve <Services.Notification.CheckingClipboardAndNotificationService>());
                unityContainer.RegisterInstance(unityContainer.Resolve <Services.Notification.NotificationFollowUpdatedService>());
                unityContainer.RegisterInstance(unityContainer.Resolve <Services.Notification.NotificationCacheRequestRejectedService>());


                // 購読機能を初期化
                try
                {
                    var watchItLater = Container.Resolve <Services.WatchItLater>();
                    watchItLater.Initialize();
                }
                catch (Exception e)
                {
                    Debug.WriteLine("購読機能の初期化に失敗");
                    Debug.WriteLine(e.ToString());
                }



                // バックグラウンドでのトースト通知ハンドリングを初期化
                await RegisterDebugToastNotificationBackgroundHandling();


                try
                {
                    var cacheManager = Container.Resolve <Models.Cache.VideoCacheManager>();
                    _ = cacheManager.Initialize();
                }
                catch { }

                /*
                 * if (args.PreviousExecutionState == ApplicationExecutionState.Terminated
                 || args.PreviousExecutionState == ApplicationExecutionState.ClosedByUser)
                 ||{
                 || if (!Services.Helpers.ApiContractHelper.Is2018FallUpdateAvailable)
                 || {
                 ||
                 || }
                 ||}
                 ||else
                 ||{
                 || var pageManager = Container.Resolve<Services.PageManager>();
                 ||
                 ||
                 #if false
                 ||try
                 ||{
                 || if (localStorge.Read(IS_COMPLETE_INTRODUCTION, false) == false)
                 || {
                 ||     // アプリのイントロダクションを開始
                 ||     pageManager.OpenIntroductionPage();
                 || }
                 || else
                 || {
                 ||     pageManager.OpenStartupPage();
                 || }
                 ||}
                 ||catch
                 ||{
                 || Debug.WriteLine("イントロダクションまたはスタートアップのページ表示に失敗");
                 || pageManager.OpenPage(HohoemaPageType.RankingCategoryList);
                 ||}
                 #else
                 || try
                 || {
                 ||     pageManager.OpenStartupPage();
                 || }
                 || catch
                 || {
                 ||     Debug.WriteLine("スタートアップのページ表示に失敗");
                 ||     pageManager.OpenPage(HohoemaPageType.RankingCategoryList);
                 || }
                 #endif
                 ||}
                 */
            }
        }
        public MenuNavigatePageBaseViewModel(
            IUnityContainer container,
            IScheduler scheduler,
            INavigationService navigationService,
            AppearanceSettings appearanceSettings,
            PinSettings pinSettings,
            NiconicoSession niconicoSession,
            LocalMylistManager localMylistManager,
            UserMylistManager userMylistManager,
            VideoCacheManager videoCacheManager,
            PageManager pageManager,
            PlayerViewManager playerViewManager,
            Services.NiconicoLoginService niconicoLoginService,
            Commands.LogoutFromNiconicoCommand logoutFromNiconicoCommand
            )
        {
            PageManager               = pageManager;
            PlayerViewManager         = playerViewManager;
            NiconicoLoginService      = niconicoLoginService;
            LogoutFromNiconicoCommand = logoutFromNiconicoCommand;
            Container          = container;
            Scheduler          = scheduler;
            NavigationService  = navigationService;
            AppearanceSettings = appearanceSettings;
            PinSettings        = pinSettings;
            NiconicoSession    = niconicoSession;
            LocalMylistManager = localMylistManager;
            UserMylistManager  = userMylistManager;
            VideoCacheManager  = videoCacheManager;

            NiconicoSession.LogIn  += (sender, e) => ResetMenuItems();
            NiconicoSession.LogOut += (sender, e) => ResetMenuItems();

            CurrentMenuType = new ReactiveProperty <MenuItemBase>();
            VideoMenu       = App.Current.Container.Resolve <VideoMenuSubPageContent>();
            LiveMenu        = App.Current.Container.Resolve <LiveMenuSubPageContent>();

            // TV Mode
            if (Services.Helpers.DeviceTypeHelper.IsXbox)
            {
                IsTVModeEnable = new ReactiveProperty <bool>(true);
            }
            else
            {
                IsTVModeEnable = AppearanceSettings.ObserveProperty(x => x.IsForceTVModeEnable)
                                 .ToReactiveProperty();
            }


            ServiceLevel = NiconicoSession.ObserveProperty(x => x.ServiceStatus)
                           .ToReadOnlyReactiveProperty(eventScheduler: Scheduler);

            IsNeedFullScreenToggleHelp
                = ApplicationView.PreferredLaunchWindowingMode == ApplicationViewWindowingMode.FullScreen;

            IsOpenPane = new ReactiveProperty <bool>(false);

            MainSelectedItem = new ReactiveProperty <HohoemaListingPageItemBase>(null, ReactivePropertyMode.DistinctUntilChanged);


            PinItems = new ObservableCollection <PinItemViewModel>(
                PinSettings.Pins.Select(x => Container.Resolve <PinItemViewModel>(new ParameterOverride("pin", x)))
                );


            bool isPinItemsChanging = false;

            PinSettings.Pins.CollectionChangedAsObservable()
            .Subscribe(args =>
            {
                if (isPinItemsChanging)
                {
                    return;
                }

                if (args.Action == System.Collections.Specialized.NotifyCollectionChangedAction.Add)
                {
                    foreach (var item in args.NewItems)
                    {
                        PinItems.Add(Container.Resolve <PinItemViewModel>(new ParameterOverride("pin", item as HohoemaPin)));
                    }
                    RaisePropertyChanged(nameof(PinItems));
                }
                else if (args.Action == System.Collections.Specialized.NotifyCollectionChangedAction.Remove)
                {
                    foreach (var item in args.OldItems)
                    {
                        var removedPin = item as HohoemaPin;
                        var pinVM      = PinItems.FirstOrDefault(x => x.Pin == removedPin);
                        if (pinVM != null)
                        {
                            PinItems.Remove(pinVM);
                        }
                    }
                    RaisePropertyChanged(nameof(PinItems));
                }
            });

            ResetMenuItems();

            // TODO; PinSettings側で自動保存するようにしたい
            PinItems.CollectionChangedAsObservable()
            .Subscribe(async _ =>
            {
                await Task.Delay(50);

                try
                {
                    isPinItemsChanging = true;
                    PinSettings.Pins.Clear();
                    foreach (var pin in PinItems)
                    {
                        PinSettings.Pins.Add(pin.Pin);
                    }
                }
                finally
                {
                    isPinItemsChanging = false;
                }
            });

            /*
             * Observable.Merge(
             *  MainSelectedItem,
             *  SubSelectedItem
             *  )
             *  .Where(x => x != null)
             *  .Subscribe(x => x.SelectedAction(x.Source));
             */
            /*
             * PageManager.ObserveProperty(x => x.CurrentPageType)
             *  .Subscribe(pageType =>
             *  {
             *      //                    IsOpenPane.Value = false;
             *
             *      bool isMenuItemOpened = false;
             *      foreach (var item in MenuItems)
             *      {
             *          if ((item as MenuItemViewModel)?.PageType == pageType)
             *          {
             *              MainSelectedItem.Value = item;
             *              isMenuItemOpened = true;
             *              break;
             *          }
             *      }
             *
             *
             *      if (!isMenuItemOpened)
             *      {
             *          MainSelectedItem.Value = null;
             *      }
             *
             *      if (Services.Helpers.DeviceTypeHelper.IsXbox || AppearanceSettings.IsForceTVModeEnable
             || Services.Helpers.DeviceTypeHelper.IsMobile
             ||     )
             ||     {
             ||         IsOpenPane.Value = false;
             ||     }
             || });
             */


            PageManager.ObserveProperty(x => x.PageTitle)
            .Subscribe(x =>
            {
                TitleText = x;
            });

            CanGoBackNavigation = new ReactiveProperty <bool>();

            (NavigationService as IPlatformNavigationService).CanGoBackChanged += (_, e) =>
            {
                CanGoBackNavigation.Value = NavigationService.CanGoBack();
            };

            /*
             * IsVisibleMenu = PageManager.ObserveProperty(x => x.CurrentPageType)
             *  .Select(x =>
             *  {
             *      return !PageManager.IsHiddenMenuPage(x);
             *  })
             *  .ToReactiveProperty(false);
             */

            NowNavigating = PageManager.ObserveProperty(x => x.PageNavigating)
                            .ToReactiveProperty();


            PageManager.StartWork    += PageManager_StartWork;
            PageManager.ProgressWork += PageManager_ProgressWork;
            PageManager.CompleteWork += PageManager_CompleteWork;
            PageManager.CancelWork   += PageManager_CancelWork;

            UserName = NiconicoSession.ObserveProperty(x => x.UserName)
                       .ToReadOnlyReactiveProperty(eventScheduler: Scheduler);

            UserIconUrl = NiconicoSession.ObserveProperty(x => x.UserIconUrl)
                          .ToReadOnlyReactiveProperty(eventScheduler: Scheduler);


            // 検索
            SearchKeyword = new ReactiveProperty <string>("");

            SearchCommand = new ReactiveCommand();
            SearchCommand
            .Subscribe(async _ =>
            {
                await Task.Delay(50);
                var keyword = SearchKeyword.Value;

                if (string.IsNullOrWhiteSpace(keyword))
                {
                    return;
                }

                SearchTarget?searchType = CurrentMenuType.Value is LiveMenuSubPageContent ? SearchTarget.Niconama : SearchTarget.Keyword;
                var searched            = Database.SearchHistoryDb.LastSearchedTarget(keyword);
                if (searched != null)
                {
                    searchType = searched;
                }

                PageManager.Search(searchType.Value, keyword);

                ResetSearchHistoryItems();
            });

            SearchSuggestionWords = new ObservableCollection <string>();



            // InAppNotification
            IsShowInAppNotification = new ReactiveProperty <bool>(true);


            // 検索履歴アイテムを初期化
            ResetSearchHistoryItems();
        }
        public MylistPageViewModel(
            ILoggerFactory loggerFactory,
            IMessenger messenger,
            ApplicationLayoutManager applicationLayoutManager,
            PageManager pageManager,
            NiconicoSession niconicoSession,
            MylistProvider mylistProvider,
            MylistFollowProvider mylistFollowProvider,
            UserProvider userProvider,
            LoginUserMylistProvider loginUserMylistProvider,
            LoginUserOwnedMylistManager userMylistManager,
            LocalMylistManager localMylistManager,
            MylistResolver mylistRepository,
            SubscriptionManager subscriptionManager,
            MylistUserSelectedSortRepository mylistUserSelectedSortRepository,
            Services.DialogService dialogService,
            AddSubscriptionCommand addSubscriptionCommand,
            SelectionModeToggleCommand selectionModeToggleCommand,
            PlaylistPlayAllCommand playlistPlayAllCommand,
            VideoPlayWithQueueCommand videoPlayWithQueueCommand
            )
        {
            _logger    = loggerFactory.CreateLogger <MylistPageViewModel>();
            _messenger = messenger;
            ApplicationLayoutManager = applicationLayoutManager;
            PageManager                       = pageManager;
            NiconicoSession                   = niconicoSession;
            MylistProvider                    = mylistProvider;
            _mylistFollowProvider             = mylistFollowProvider;
            UserProvider                      = userProvider;
            LoginUserMylistProvider           = loginUserMylistProvider;
            UserMylistManager                 = userMylistManager;
            LocalMylistManager                = localMylistManager;
            _mylistRepository                 = mylistRepository;
            SubscriptionManager               = subscriptionManager;
            _mylistUserSelectedSortRepository = mylistUserSelectedSortRepository;
            DialogService                     = dialogService;
            AddSubscriptionCommand            = addSubscriptionCommand;
            SelectionModeToggleCommand        = selectionModeToggleCommand;
            PlaylistPlayAllCommand            = playlistPlayAllCommand;
            VideoPlayWithQueueCommand         = videoPlayWithQueueCommand;
            Mylist = new ReactiveProperty <MylistPlaylist>();

            SelectedSortOptionItem = new ReactiveProperty <MylistPlaylistSortOption>(mode: ReactivePropertyMode.DistinctUntilChanged);

            CurrentPlaylistToken = Observable.CombineLatest(
                Mylist,
                SelectedSortOptionItem,
                (x, y) => new PlaylistToken(x, y)
                )
                                   .ToReadOnlyReactivePropertySlim()
                                   .AddTo(_CompositeDisposable);


            /*
             * IsFavoriteMylist = new ReactiveProperty<bool>(mode: ReactivePropertyMode.DistinctUntilChanged)
             *  .AddTo(_CompositeDisposable);
             * CanChangeFavoriteMylistState = new ReactiveProperty<bool>()
             *  .AddTo(_CompositeDisposable);
             *
             *
             * IsFavoriteMylist
             *  .Where(x => PlayableList.Value.Id != null)
             *  .Subscribe(async x =>
             *  {
             *      if (PlayableList.Value.Origin != PlaylistOrigin.OtherUser) { return; }
             *
             *      if (_NowProcessFavorite) { return; }
             *
             *      _NowProcessFavorite = true;
             *
             *      CanChangeFavoriteMylistState.Value = false;
             *      if (x)
             *      {
             *          if (await FavoriteMylist())
             *          {
             *              Debug.WriteLine(_MylistTitle + "のマイリストをお気に入り登録しました.");
             *          }
             *          else
             *          {
             *              // お気に入り登録に失敗した場合は状態を差し戻し
             *              Debug.WriteLine(_MylistTitle + "のマイリストをお気に入り登録に失敗");
             *              IsFavoriteMylist.Value = false;
             *          }
             *      }
             *      else
             *      {
             *          if (await UnfavoriteMylist())
             *          {
             *              Debug.WriteLine(_MylistTitle + "のマイリストをお気に入り解除しました.");
             *          }
             *          else
             *          {
             *              // お気に入り解除に失敗した場合は状態を差し戻し
             *              Debug.WriteLine(_MylistTitle + "のマイリストをお気に入り解除に失敗");
             *              IsFavoriteMylist.Value = true;
             *          }
             *      }
             *
             *      CanChangeFavoriteMylistState.Value =
             *          IsFavoriteMylist.Value == true
             || FollowManager.CanMoreAddFollow(FollowItemType.Mylist);
             ||
             ||
             ||     _NowProcessFavorite = false;
             || })
             || .AddTo(_CompositeDisposable);
             ||
             ||
             ||UnregistrationMylistCommand = SelectedItems.ObserveProperty(x => x.Count)
             || .Where(_ => IsUserOwnerdMylist)
             || .Select(x => x > 0)
             || .ToReactiveCommand(false);
             ||
             ||UnregistrationMylistCommand.Subscribe(async _ =>
             ||{
             || if (PlayableList.Value.Origin == PlaylistOrigin.Local)
             || {
             ||     var localMylist = PlayableList.Value as LegacyLocalMylist;
             ||     var items = SelectedItems.ToArray();
             ||
             ||     foreach (var item in items)
             ||     {
             ||         localMylist.Remove(item.PlaylistItem);
             ||         IncrementalLoadingItems.Remove(item);
             ||     }
             || }
             || else if (PlayableList.Value.Origin == PlaylistOrigin.LoginUser)
             || {
             ||     var mylistGroup = HohoemaApp.UserMylistManager.GetMylistGroup(PlayableList.Value.Id);
             ||
             ||     var items = SelectedItems.ToArray();
             ||
             ||
             ||     var action = AsyncInfo.Run<uint>(async (cancelToken, progress) =>
             ||     {
             ||         uint progressCount = 0;
             ||         int successCount = 0;
             ||         int failedCount = 0;
             ||
             ||         Debug.WriteLine($"マイリストに追加解除を開始...");
             ||         foreach (var video in items)
             ||         {
             ||             var unregistrationResult = await mylistGroup.Unregistration(
             ||                 video.RawVideoId
             ||                 , withRefresh: false );
             ||
             ||             if (unregistrationResult == ContentManageResult.Success)
             ||             {
             ||                 successCount++;
             ||             }
             ||             else
             ||             {
             ||                 failedCount++;
             ||             }
             ||
             ||             progressCount++;
             ||             progress.Report(progressCount);
             ||
             ||             Debug.WriteLine($"{video.Label}[{video.RawVideoId}]:{unregistrationResult.ToString()}");
             ||         }
             ||
             ||         // 登録解除結果を得るためリフレッシュ
             ||         await mylistGroup.Refresh();
             ||
             ||
             ||         // ユーザーに結果を通知
             ||         var titleText = $"「{mylistGroup.Label}」から {successCount}件 の動画が登録解除されました";
             ||         var toastService = Microsoft.Toolkit.Mvvm.DependencyInjection.Ioc.Default.GetService<NotificationService>();
             ||         var resultText = $"";
             ||         if (failedCount > 0)
             ||         {
             ||             resultText += $"\n登録解除に失敗した {failedCount}件 は選択されたままです";
             ||         }
             ||         toastService.ShowToast(titleText, resultText);
             ||
             ||         // 登録解除に失敗したアイテムだけを残すように
             ||         // マイリストから除外された動画を選択アイテムリストから削除
             ||         foreach (var item in SelectedItems.ToArray())
             ||         {
             ||             if (false == mylistGroup.CheckRegistratedVideoId(item.RawVideoId))
             ||             {
             ||                 SelectedItems.Remove(item);
             ||                 IncrementalLoadingItems.Remove(item);
             ||             }
             ||         }
             ||
             ||         Debug.WriteLine($"マイリストに追加解除完了---------------");
             ||     });
             ||
             ||     await PageManager.StartNoUIWork("マイリストに追加解除", items.Length, () => action);
             ||
             || }
             ||
             ||
             ||});
             ||
             ||
             */
        }
        public MylistPageViewModel(
            Services.PageManager pageManager,
            NiconicoSession niconicoSession,
            MylistProvider mylistProvider,
            UserProvider userProvider,
            FollowManager followManager,
            LoginUserMylistProvider loginUserMylistProvider,
            NGSettings ngSettings,
            UserMylistManager userMylistManager,
            LocalMylistManager localMylistManager,
            Services.HohoemaPlaylist hohoemaPlaylist,
            SubscriptionManager subscriptionManager,
            Services.DialogService dialogService,
            NiconicoFollowToggleButtonService followToggleButtonService,
            Services.Helpers.MylistHelper mylistHelper,
            Commands.Subscriptions.CreateSubscriptionGroupCommand createSubscriptionGroupCommand
            )
            : base(pageManager)
        {
            NiconicoSession         = niconicoSession;
            MylistProvider          = mylistProvider;
            UserProvider            = userProvider;
            FollowManager           = followManager;
            LoginUserMylistProvider = loginUserMylistProvider;
            NgSettings                     = ngSettings;
            UserMylistManager              = userMylistManager;
            LocalMylistManager             = localMylistManager;
            HohoemaPlaylist                = hohoemaPlaylist;
            SubscriptionManager            = subscriptionManager;
            DialogService                  = dialogService;
            FollowToggleButtonService      = followToggleButtonService;
            MylistHelper                   = mylistHelper;
            CreateSubscriptionGroupCommand = createSubscriptionGroupCommand;
            Mylist       = new ReactiveProperty <Interfaces.IMylist>();
            MylistOrigin = new ReactiveProperty <Services.PlaylistOrigin>();

            /*
             * IsFavoriteMylist = new ReactiveProperty<bool>(mode: ReactivePropertyMode.DistinctUntilChanged)
             *  .AddTo(_CompositeDisposable);
             * CanChangeFavoriteMylistState = new ReactiveProperty<bool>()
             *  .AddTo(_CompositeDisposable);
             *
             *
             * IsFavoriteMylist
             *  .Where(x => PlayableList.Value.Id != null)
             *  .Subscribe(async x =>
             *  {
             *      if (PlayableList.Value.Origin != PlaylistOrigin.OtherUser) { return; }
             *
             *      if (_NowProcessFavorite) { return; }
             *
             *      _NowProcessFavorite = true;
             *
             *      CanChangeFavoriteMylistState.Value = false;
             *      if (x)
             *      {
             *          if (await FavoriteMylist())
             *          {
             *              Debug.WriteLine(_MylistTitle + "のマイリストをお気に入り登録しました.");
             *          }
             *          else
             *          {
             *              // お気に入り登録に失敗した場合は状態を差し戻し
             *              Debug.WriteLine(_MylistTitle + "のマイリストをお気に入り登録に失敗");
             *              IsFavoriteMylist.Value = false;
             *          }
             *      }
             *      else
             *      {
             *          if (await UnfavoriteMylist())
             *          {
             *              Debug.WriteLine(_MylistTitle + "のマイリストをお気に入り解除しました.");
             *          }
             *          else
             *          {
             *              // お気に入り解除に失敗した場合は状態を差し戻し
             *              Debug.WriteLine(_MylistTitle + "のマイリストをお気に入り解除に失敗");
             *              IsFavoriteMylist.Value = true;
             *          }
             *      }
             *
             *      CanChangeFavoriteMylistState.Value =
             *          IsFavoriteMylist.Value == true
             || FollowManager.CanMoreAddFollow(FollowItemType.Mylist);
             ||
             ||
             ||     _NowProcessFavorite = false;
             || })
             || .AddTo(_CompositeDisposable);
             ||
             ||
             ||UnregistrationMylistCommand = SelectedItems.ObserveProperty(x => x.Count)
             || .Where(_ => IsUserOwnerdMylist)
             || .Select(x => x > 0)
             || .ToReactiveCommand(false);
             ||
             ||UnregistrationMylistCommand.Subscribe(async _ =>
             ||{
             || if (PlayableList.Value.Origin == PlaylistOrigin.Local)
             || {
             ||     var localMylist = PlayableList.Value as LegacyLocalMylist;
             ||     var items = SelectedItems.ToArray();
             ||
             ||     foreach (var item in items)
             ||     {
             ||         localMylist.Remove(item.PlaylistItem);
             ||         IncrementalLoadingItems.Remove(item);
             ||     }
             || }
             || else if (PlayableList.Value.Origin == PlaylistOrigin.LoginUser)
             || {
             ||     var mylistGroup = HohoemaApp.UserMylistManager.GetMylistGroup(PlayableList.Value.Id);
             ||
             ||     var items = SelectedItems.ToArray();
             ||
             ||
             ||     var action = AsyncInfo.Run<uint>(async (cancelToken, progress) =>
             ||     {
             ||         uint progressCount = 0;
             ||         int successCount = 0;
             ||         int failedCount = 0;
             ||
             ||         Debug.WriteLine($"マイリストに追加解除を開始...");
             ||         foreach (var video in items)
             ||         {
             ||             var unregistrationResult = await mylistGroup.Unregistration(
             ||                 video.RawVideoId
             ||                 , withRefresh: false );
             ||
             ||             if (unregistrationResult == ContentManageResult.Success)
             ||             {
             ||                 successCount++;
             ||             }
             ||             else
             ||             {
             ||                 failedCount++;
             ||             }
             ||
             ||             progressCount++;
             ||             progress.Report(progressCount);
             ||
             ||             Debug.WriteLine($"{video.Label}[{video.RawVideoId}]:{unregistrationResult.ToString()}");
             ||         }
             ||
             ||         // 登録解除結果を得るためリフレッシュ
             ||         await mylistGroup.Refresh();
             ||
             ||
             ||         // ユーザーに結果を通知
             ||         var titleText = $"「{mylistGroup.Label}」から {successCount}件 の動画が登録解除されました";
             ||         var toastService = App.Current.Container.Resolve<NotificationService>();
             ||         var resultText = $"";
             ||         if (failedCount > 0)
             ||         {
             ||             resultText += $"\n登録解除に失敗した {failedCount}件 は選択されたままです";
             ||         }
             ||         toastService.ShowToast(titleText, resultText);
             ||
             ||         // 登録解除に失敗したアイテムだけを残すように
             ||         // マイリストから除外された動画を選択アイテムリストから削除
             ||         foreach (var item in SelectedItems.ToArray())
             ||         {
             ||             if (false == mylistGroup.CheckRegistratedVideoId(item.RawVideoId))
             ||             {
             ||                 SelectedItems.Remove(item);
             ||                 IncrementalLoadingItems.Remove(item);
             ||             }
             ||         }
             ||
             ||         Debug.WriteLine($"マイリストに追加解除完了---------------");
             ||     });
             ||
             ||     await PageManager.StartNoUIWork("マイリストに追加解除", items.Length, () => action);
             ||
             || }
             ||
             ||
             ||});
             ||
             ||
             */
        }
Beispiel #26
0
        public UserMylistPageViewModel(
            Services.PageManager pageMaanger,
            Services.DialogService dialogService,
            NiconicoSession niconicoSession,
            UserProvider userProvider,
            LoginUserMylistProvider loginUserMylistProvider,
            OtherOwneredMylistManager otherOwneredMylistManager,
            UserMylistManager userMylistManager,
            LocalMylistManager localMylistManager,
            HohoemaPlaylist hohoemaPlaylist
            )
            : base(pageMaanger, useDefaultPageTitle: false)
        {
            DialogService             = dialogService;
            NiconicoSession           = niconicoSession;
            UserProvider              = userProvider;
            LoginUserMylistProvider   = loginUserMylistProvider;
            OtherOwneredMylistManager = otherOwneredMylistManager;
            UserMylistManager         = userMylistManager;
            LocalMylistManager        = localMylistManager;
            HohoemaPlaylist           = hohoemaPlaylist;
            IsLoginUserMylist         = new ReactiveProperty <bool>(false);

            OpenMylistCommand = new ReactiveCommand <Interfaces.IMylist>();

            OpenMylistCommand.Subscribe(listItem =>
            {
                PageManager.OpenPage(HohoemaPageType.Mylist,
                                     new MylistPagePayload()
                {
                    Id = listItem.Id, Origin = listItem.ToMylistOrigin()
                }
                                     .ToParameterString()
                                     );
            });

            AddMylistGroupCommand = new DelegateCommand(async() =>
            {
                MylistGroupEditData data = new MylistGroupEditData()
                {
                    Name              = "新しいマイリスト",
                    Description       = "",
                    IsPublic          = false,
                    MylistDefaultSort = MylistDefaultSort.Latest,
                    IconType          = IconType.Default,
                };

                // 成功するかキャンセルが押されるまで繰り返す
                while (true)
                {
                    if (true == await DialogService.ShowCreateMylistGroupDialogAsync(data))
                    {
                        var result = await UserMylistManager.AddMylist(
                            data.Name,
                            data.Description,
                            data.IsPublic,
                            data.MylistDefaultSort,
                            data.IconType
                            );

                        if (result == Mntone.Nico2.ContentManageResult.Success)
                        {
                            await ResetList();
                            break;
                        }
                    }
                    else
                    {
                        break;
                    }
                }
            }
                                                        , () => UserMylistManager.Mylists.Count < UserMylistManager.MaxMylistGroupCountCurrentUser
                                                        );

            RemoveMylistGroupCommand = new DelegateCommand <Interfaces.IMylist>(async(item) =>
            {
                var mylistOrigin = item.ToMylistOrigin();
                if (mylistOrigin == PlaylistOrigin.Local)
                {
                    if (item.Id == HohoemaPlaylist.WatchAfterPlaylistId)
                    {
                        return;
                    }
                }
                else if (mylistOrigin == PlaylistOrigin.LoginUser)
                {
                    if (item.Id == "0")
                    {
                        return;
                    }
                }

                // 確認ダイアログ
                var originText     = mylistOrigin == PlaylistOrigin.Local ? "ローカルマイリスト" : "マイリスト";
                var contentMessage = $"{item.Label} を削除してもよろしいですか?(変更は元に戻せません)";

                var dialog = new MessageDialog(contentMessage, $"{originText}削除の確認");
                dialog.Commands.Add(new UICommand("削除", async(i) =>
                {
                    if (mylistOrigin == PlaylistOrigin.Local)
                    {
                        LocalMylistManager.RemoveCommand.Execute(item as LocalMylistGroup);
                    }
                    else if (mylistOrigin == PlaylistOrigin.LoginUser)
                    {
                        await UserMylistManager.RemoveMylist(item.Id);
                        //                        await UpdateUserMylist();
                    }
                }));

                dialog.Commands.Add(new UICommand("キャンセル"));
                dialog.CancelCommandIndex  = 1;
                dialog.DefaultCommandIndex = 1;

                await dialog.ShowAsync();
            });


            EditMylistGroupCommand = new DelegateCommand <Interfaces.IMylist>(async item =>
            {
                var mylistOrigin = item.ToMylistOrigin();
                if (mylistOrigin == PlaylistOrigin.Local)
                {
                    if (item.Id == HohoemaPlaylist.WatchAfterPlaylistId)
                    {
                        return;
                    }
                }
                else if (mylistOrigin == PlaylistOrigin.LoginUser)
                {
                    if (item.Id == "0")
                    {
                        return;
                    }
                }

                if (mylistOrigin == PlaylistOrigin.Local)
                {
                    var localMylist = item as LocalMylistGroup;
                    var resultText  = await DialogService.GetTextAsync("プレイリスト名を変更",
                                                                       localMylist.Label,
                                                                       localMylist.Label,
                                                                       (tempName) => !string.IsNullOrWhiteSpace(tempName)
                                                                       );

                    if (!string.IsNullOrWhiteSpace(resultText))
                    {
                        localMylist.Label = resultText;
                    }
                }


                if (mylistOrigin == PlaylistOrigin.LoginUser)
                {
                    var mylistGroupListItem   = item as UserOwnedMylist;
                    var selectedMylistGroupId = mylistGroupListItem.Id;

                    if (selectedMylistGroupId == null)
                    {
                        return;
                    }

                    var mylistGroup          = UserMylistManager.GetMylistGroup(selectedMylistGroupId);
                    MylistGroupEditData data = new MylistGroupEditData()
                    {
                        Name              = mylistGroup.Label,
                        Description       = mylistGroup.Description,
                        IsPublic          = mylistGroup.IsPublic,
                        MylistDefaultSort = mylistGroup.Sort,
                        IconType          = mylistGroup.IconType,
                    };

                    // 成功するかキャンセルが押されるまで繰り返す
                    while (true)
                    {
                        if (true == await DialogService.ShowCreateMylistGroupDialogAsync(data))
                        {
                            mylistGroup.Label       = data.Name;
                            mylistGroup.Description = data.Description;
                            mylistGroup.IsPublic    = data.IsPublic;
                            mylistGroup.Sort        = data.MylistDefaultSort;
                            mylistGroup.IconType    = data.IconType;
                            var result = await LoginUserMylistProvider.UpdateMylist(mylistGroup);

                            if (result == Mntone.Nico2.ContentManageResult.Success)
                            {
                                // TODO: UI上のマイリスト表示を更新する
                                break;
                            }
                        }
                        else
                        {
                            break;
                        }
                    }
                }
            });

            PlayAllCommand = new DelegateCommand <Interfaces.IMylist>((mylist) =>
            {
                if (mylist.ItemCount == 0)
                {
                    return;
                }

                HohoemaPlaylist.Play(mylist);
            });



            AddLocalMylistCommand = new DelegateCommand(async() =>
            {
                var name = await DialogService.GetTextAsync("新しいローカルマイリスト名を入力", "ローカルマイリスト名", "",
                                                            (s) =>
                {
                    if (string.IsNullOrWhiteSpace(s))
                    {
                        return(false);
                    }

                    if (LocalMylistManager.Mylists.Any(x => x.Label == s))
                    {
                        return(false);
                    }

                    return(true);
                });

                if (name != null)
                {
                    LocalMylistManager.Mylists.Add(new LocalMylistGroup(Guid.NewGuid().ToString(), name));
                }
            });
        }
Beispiel #27
0
        public UserMylistPageViewModel(
            ApplicationLayoutManager applicationLayoutManager,
            Services.PageManager pageManager,
            Services.DialogService dialogService,
            NiconicoSession niconicoSession,
            UserProvider userProvider,
            MylistRepository mylistRepository,
            UserMylistManager userMylistManager,
            LocalMylistManager localMylistManager,
            HohoemaPlaylist hohoemaPlaylist,
            CreateLocalMylistCommand createLocalMylistCommand
            )
        {
            ApplicationLayoutManager = applicationLayoutManager;
            PageManager              = pageManager;
            DialogService            = dialogService;
            NiconicoSession          = niconicoSession;
            UserProvider             = userProvider;
            _mylistRepository        = mylistRepository;
            _userMylistManager       = userMylistManager;
            _localMylistManager      = localMylistManager;
            CreateLocalMylistCommand = createLocalMylistCommand;
            HohoemaPlaylist          = hohoemaPlaylist;
            IsLoginUserMylist        = new ReactiveProperty <bool>(false);

            OpenMylistCommand = new ReactiveCommand <IPlaylist>();

            OpenMylistCommand.Subscribe(listItem =>
            {
                PageManager.OpenPage(HohoemaPageType.Mylist, $"id={listItem.Id}");
            });

            AddMylistGroupCommand = new DelegateCommand(async() =>
            {
                MylistGroupEditData data = new MylistGroupEditData()
                {
                    Name              = "",
                    Description       = "",
                    IsPublic          = false,
                    MylistDefaultSort = MylistDefaultSort.Latest,
                    IconType          = IconType.Default,
                };

                // 成功するかキャンセルが押されるまで繰り返す
                while (true)
                {
                    if (true == await DialogService.ShowCreateMylistGroupDialogAsync(data))
                    {
                        var result = await _userMylistManager.AddMylist(
                            data.Name,
                            data.Description,
                            data.IsPublic,
                            data.MylistDefaultSort,
                            data.IconType
                            );

                        if (result == Mntone.Nico2.ContentManageResult.Success)
                        {
                            await ResetList();
                            break;
                        }
                    }
                    else
                    {
                        break;
                    }
                }
            }
                                                        , () => _userMylistManager.Mylists.Count < _userMylistManager.MaxMylistGroupCountCurrentUser
                                                        );

            RemoveMylistGroupCommand = new DelegateCommand <Interfaces.IPlaylist>(async(item) =>
            {
                {
                    if (item is LocalPlaylist localPlaylist)
                    {
                        if (localPlaylist.IsWatchAfterPlaylist())
                        {
                            return;
                        }
                    }
                    else if (item is LoginUserMylistPlaylist loginUserMylist)
                    {
                        if (loginUserMylist.IsDefaultMylist())
                        {
                            return;
                        }
                    }
                }

                // 確認ダイアログ
                var contentMessage = "ConfirmDeleteX_ImpossibleReDo".Translate(item.Label);

                var dialog = new MessageDialog(contentMessage, "ConfirmDeleteX".Translate(item.GetOrigin().Translate()));
                dialog.Commands.Add(new UICommand("Delete".Translate(), async(i) =>
                {
                    if (item is LocalPlaylist localPlaylist)
                    {
                        _localMylistManager.RemovePlaylist(localPlaylist);
                    }
                    else if (item is LoginUserMylistPlaylist loginUserMylist)
                    {
                        await _userMylistManager.RemoveMylist(item.Id);
                    }
                }));

                dialog.Commands.Add(new UICommand("Cancel".Translate()));
                dialog.CancelCommandIndex  = 1;
                dialog.DefaultCommandIndex = 1;

                await dialog.ShowAsync();
            });


            EditMylistGroupCommand = new DelegateCommand <Interfaces.IPlaylist>(async item =>
            {
                if (item is LocalPlaylist localPlaylist)
                {
                    if (item.Id == HohoemaPlaylist.WatchAfterPlaylistId)
                    {
                        return;
                    }

                    var resultText = await DialogService.GetTextAsync("RenameLocalPlaylist".Translate(),
                                                                      localPlaylist.Label,
                                                                      localPlaylist.Label,
                                                                      (tempName) => !string.IsNullOrWhiteSpace(tempName)
                                                                      );

                    if (!string.IsNullOrWhiteSpace(resultText))
                    {
                        localPlaylist.Label = resultText;
                    }
                }
                else if (item is LoginUserMylistPlaylist loginUserMylist)
                {
                    if (loginUserMylist.IsDefaultMylist())
                    {
                        return;
                    }

                    MylistGroupEditData data = new MylistGroupEditData()
                    {
                        Name              = loginUserMylist.Label,
                        Description       = loginUserMylist.Description,
                        IsPublic          = loginUserMylist.IsPublic,
                        MylistDefaultSort = loginUserMylist.DefaultSort,
                        IconType          = loginUserMylist.IconType,
                    };

                    // 成功するかキャンセルが押されるまで繰り返す
                    while (true)
                    {
                        if (true == await DialogService.ShowCreateMylistGroupDialogAsync(data))
                        {
                            var result = await loginUserMylist.UpdateMylist(data);

                            if (result == Mntone.Nico2.ContentManageResult.Success)
                            {
                                loginUserMylist.Label       = data.Name;
                                loginUserMylist.Description = data.Description;
                                loginUserMylist.IsPublic    = data.IsPublic;
                                loginUserMylist.DefaultSort = data.MylistDefaultSort;
                                loginUserMylist.IconType    = data.IconType;

                                break;
                            }
                        }
                        else
                        {
                            break;
                        }
                    }
                }
            });
        }
        public VideoPlayerPageViewModel(
            ILoggerFactory loggerFactory,
            IScheduler scheduler,
            IPlayerView playerView,
            NiconicoSession niconicoSession,
            SubscriptionManager subscriptionManager,
            NicoVideoProvider nicoVideoProvider,
            ChannelProvider channelProvider,
            MylistProvider mylistProvider,
            AppearanceSettings appearanceSettings,
            PlayerSettings playerSettings,
            VideoCacheSettings_Legacy cacheSettings,
            ApplicationLayoutManager applicationLayoutManager,
            LocalMylistManager localMylistManager,
            LoginUserOwnedMylistManager userMylistManager,
            PageManager pageManager,
            QueuePlaylist queuePlaylist,
            HohoemaPlaylistPlayer hohoemaPlaylistPlayer,
            MediaPlayer mediaPlayer,
            VideoTogglePlayPauseCommand videoTogglePlayPauseCommand,
            NotificationService notificationService,
            DialogService dialogService,
            AddSubscriptionCommand addSubscriptionCommand,
            LocalPlaylistCreateCommand createLocalMylistCommand,
            MylistAddItemCommand addMylistCommand,
            LocalPlaylistAddItemCommand localPlaylistAddItemCommand,
            MylistCreateCommand createMylistCommand,
            VideoStreamingOriginOrchestrator videoStreamingOriginOrchestrator,
            VideoCommentPlayer commentPlayer,
            CommentCommandEditerViewModel commentCommandEditerViewModel,
            KeepActiveDisplayWhenPlaying keepActiveDisplayWhenPlaying,
            ObservableMediaPlayer observableMediaPlayer,
            VideoEndedRecommendation videoEndedRecommendation,
            PrimaryViewPlayerManager primaryViewPlayerManager,
            TogglePlayerDisplayViewCommand togglePlayerDisplayViewCommand,
            ShowPrimaryViewCommand showPrimaryViewCommand,
            MediaPlayerSoundVolumeManager soundVolumeManager,
            OpenLinkCommand openLinkCommand,
            CopyToClipboardCommand copyToClipboardCommand,
            ChangeVideoQualityCommand changeVideoQualityCommand,
            CopyToClipboardWithShareTextCommand copyToClipboardWithShareTextCommand,
            OpenShareUICommand openShareUICommand,
            PlaylistSidePaneContentViewModel playlistSidePaneContentViewModel,
            SettingsSidePaneContentViewModel settingsSidePaneContentViewModel,
            VideoCommentSidePaneContentViewModel videoCommentSidePaneContent,
            RelatedVideosSidePaneContentViewModel relatedVideosSidePaneContentViewModel
            )
        {
            _logger = loggerFactory.CreateLogger <VideoPlayerPageViewModel>();
            CurrentPlayerDisplayView = appearanceSettings
                                       .ObserveProperty(x => x.PlayerDisplayView)
                                       .ToReadOnlyReactivePropertySlim()
                                       .AddTo(_CompositeDisposable);

            _scheduler                             = scheduler;
            PlayerView                             = playerView;
            NiconicoSession                        = niconicoSession;
            SubscriptionManager                    = subscriptionManager;
            NicoVideoProvider                      = nicoVideoProvider;
            ChannelProvider                        = channelProvider;
            MylistProvider                         = mylistProvider;
            PlayerSettings                         = playerSettings;
            CacheSettings                          = cacheSettings;
            ApplicationLayoutManager               = applicationLayoutManager;
            LocalMylistManager                     = localMylistManager;
            UserMylistManager                      = userMylistManager;
            PageManager                            = pageManager;
            _queuePlaylist                         = queuePlaylist;
            _hohoemaPlaylistPlayer                 = hohoemaPlaylistPlayer;
            _NotificationService                   = notificationService;
            _HohoemaDialogService                  = dialogService;
            AddSubscriptionCommand                 = addSubscriptionCommand;
            CreateLocalMylistCommand               = createLocalMylistCommand;
            AddMylistCommand                       = addMylistCommand;
            LocalPlaylistAddItemCommand            = localPlaylistAddItemCommand;
            CreateMylistCommand                    = createMylistCommand;
            _videoStreamingOriginOrchestrator      = videoStreamingOriginOrchestrator;
            CommentPlayer                          = commentPlayer;
            CommentCommandEditerViewModel          = commentCommandEditerViewModel;
            PrimaryViewPlayerManager               = primaryViewPlayerManager;
            TogglePlayerDisplayViewCommand         = togglePlayerDisplayViewCommand;
            ShowPrimaryViewCommand                 = showPrimaryViewCommand;
            SoundVolumeManager                     = soundVolumeManager;
            OpenLinkCommand                        = openLinkCommand;
            CopyToClipboardCommand                 = copyToClipboardCommand;
            ChangeVideoQualityCommand              = changeVideoQualityCommand;
            CopyToClipboardWithShareTextCommand    = copyToClipboardWithShareTextCommand;
            OpenShareUICommand                     = openShareUICommand;
            _playlistSidePaneContentViewModel      = playlistSidePaneContentViewModel;
            _settingsSidePaneContentViewModel      = settingsSidePaneContentViewModel;
            _videoCommentSidePaneContentViewModel  = videoCommentSidePaneContent;
            _relatedVideosSidePaneContentViewModel = relatedVideosSidePaneContentViewModel;
            ObservableMediaPlayer                  = observableMediaPlayer
                                                     .AddTo(_CompositeDisposable);
            VideoEndedRecommendation = videoEndedRecommendation
                                       .AddTo(_CompositeDisposable);
            _keepActiveDisplayWhenPlaying = keepActiveDisplayWhenPlaying
                                            .AddTo(_CompositeDisposable);
            MediaPlayer = mediaPlayer;
            VideoTogglePlayPauseCommand = videoTogglePlayPauseCommand;
            SeekCommand            = new MediaPlayerSeekCommand(MediaPlayer);
            SetPlaybackRateCommand = new MediaPlayerSetPlaybackRateCommand(MediaPlayer);
            ToggleMuteCommand      = new MediaPlayerToggleMuteCommand(MediaPlayer);
            VolumeUpCommand        = new MediaPlayerVolumeUpCommand(SoundVolumeManager);
            VolumeDownCommand      = new MediaPlayerVolumeDownCommand(SoundVolumeManager);

            PlayNextCommand = _hohoemaPlaylistPlayer.GetCanGoNextOrPreviewObservable()
                              .SelectMany(async x => await _hohoemaPlaylistPlayer.CanGoNextAsync())
                              .ToAsyncReactiveCommand()
                              .AddTo(_CompositeDisposable);

            PlayNextCommand.Subscribe(async() => await _hohoemaPlaylistPlayer.GoNextAsync(NavigationCancellationToken))
            .AddTo(_CompositeDisposable);

            PlayPreviousCommand = _hohoemaPlaylistPlayer.GetCanGoNextOrPreviewObservable()
                                  .SelectMany(async x => await _hohoemaPlaylistPlayer.CanGoPreviewAsync())
                                  .ToAsyncReactiveCommand()
                                  .AddTo(_CompositeDisposable);

            PlayPreviousCommand.Subscribe(async() => await _hohoemaPlaylistPlayer.GoPreviewAsync(NavigationCancellationToken))
            .AddTo(_CompositeDisposable);

            IsLoopingEnabled = PlayerSettings.ToReactivePropertyAsSynchronized(x => x.IsCurrentVideoLoopingEnabled, raiseEventScheduler: scheduler)
                               .AddTo(_CompositeDisposable);
            IsLoopingEnabled.Subscribe(x => mediaPlayer.IsLoopingEnabled = x)
            .AddTo(_CompositeDisposable);

            IsPlaylistShuffleRequeted = PlayerSettings.ToReactivePropertyAsSynchronized(x => x.IsShuffleEnable, _scheduler)
                                        .AddTo(_CompositeDisposable);

            IsAvailablePlaylistRepeatOrShuffle = _hohoemaPlaylistPlayer.ObserveProperty(x => x.IsShuffleAndRepeatAvailable)
                                                 .ToReadOnlyReactiveProperty();
        }