public LiveVideoPlayerControlViewModel( HohoemaApp hohoemaApp, PageManager pageManager, TextInputDialogService textInputDialogService, ToastNotificationService toast ) : base(hohoemaApp, pageManager, canActivateBackgroundUpdate: true) { _TextInputDialogService = textInputDialogService; _ToastNotificationService = toast; MediaPlayer = HohoemaApp.MediaPlayer; // play CurrentState = new ReactiveProperty <MediaElementState>(); NowPlaying = CurrentState.Select(x => x == MediaElementState.Playing) .ToReactiveProperty(); NowUpdating = new ReactiveProperty <bool>(false); LivePlayerType = new ReactiveProperty <Models.Live.LivePlayerType?>(); CanChangeQuality = new ReactiveProperty <bool>(false); RequestQuality = new ReactiveProperty <string>(); CurrentQuality = new ReactiveProperty <string>(); IsAvailableSuperLowQuality = new ReactiveProperty <bool>(false); IsAvailableLowQuality = new ReactiveProperty <bool>(false); IsAvailableNormalQuality = new ReactiveProperty <bool>(false); IsAvailableHighQuality = new ReactiveProperty <bool>(false); ChangeQualityCommand = new DelegateCommand <string>( (quality) => { NicoLiveVideo.ChangeQualityRequest(quality).ConfigureAwait(false); HohoemaApp.UserSettings.PlayerSettings.DefaultLiveQuality = quality; HohoemaApp.UserSettings.PlayerSettings.Save().ConfigureAwait(false); }, (quality) => NicoLiveVideo.Qualities.Any(x => x == quality) ); IsVisibleComment = new ReactiveProperty <bool>(PlayerWindowUIDispatcherScheduler, true).AddTo(_CompositeDisposable); CommentCanvasHeight = new ReactiveProperty <double>(PlayerWindowUIDispatcherScheduler, 0.0).AddTo(_CompositeDisposable); CommentDefaultColor = new ReactiveProperty <Color>(PlayerWindowUIDispatcherScheduler, Colors.White).AddTo(_CompositeDisposable); CommentOpacity = HohoemaApp.UserSettings.PlayerSettings.ObserveProperty(x => x.CommentOpacity) .Select(x => x.ToOpacity()) .ToReadOnlyReactiveProperty(eventScheduler: PlayerWindowUIDispatcherScheduler); // post comment WritingComment = new ReactiveProperty <string>(PlayerWindowUIDispatcherScheduler, "").AddTo(_CompositeDisposable); NowCommentWriting = new ReactiveProperty <bool>(PlayerWindowUIDispatcherScheduler).AddTo(_CompositeDisposable); NowSubmittingComment = new ReactiveProperty <bool>(PlayerWindowUIDispatcherScheduler).AddTo(_CompositeDisposable); // TODO: ニコ生での匿名コメント設定 CommandString = new ReactiveProperty <string>(PlayerWindowUIDispatcherScheduler, "").AddTo(_CompositeDisposable); CommandEditerVM = new CommentCommandEditerViewModel(true /* isDefaultAnnonymous */); CommandEditerVM.OnCommandChanged += CommandEditerVM_OnCommandChanged; CommandEditerVM.ChangeEnableAnonymity(true); CommandEditerVM.IsAnonymousComment.Value = true; CommandEditerVM_OnCommandChanged(); CommentSubmitCommand = Observable.CombineLatest( WritingComment.Select(x => !string.IsNullOrEmpty(x)), NowSubmittingComment.Select(x => !x) ) .Select(x => x.All(y => y)) .ToReactiveCommand(PlayerWindowUIDispatcherScheduler) .AddTo(_CompositeDisposable); CommentSubmitCommand.Subscribe(async x => { if (NicoLiveVideo != null) { NowSubmittingComment.Value = true; await NicoLiveVideo.PostComment(WritingComment.Value, CommandString.Value, LiveElapsedTime); } }); // operation command PermanentDisplayText = new ReactiveProperty <string>(PlayerWindowUIDispatcherScheduler, "").AddTo(_CompositeDisposable); // sound IsFullScreen = new ReactiveProperty <bool>(PlayerWindowUIDispatcherScheduler, false).AddTo(_CompositeDisposable); IsFullScreen .Subscribe(isFullScreen => { var appView = ApplicationView.GetForCurrentView(); if (isFullScreen) { if (!appView.TryEnterFullScreenMode()) { IsFullScreen.Value = false; } } else { appView.ExitFullScreenMode(); } }) .AddTo(_CompositeDisposable); IsSmallWindowModeEnable = HohoemaApp.Playlist .ToReactivePropertyAsSynchronized(x => x.IsPlayerFloatingModeEnable); IsAutoHideEnable = Observable.CombineLatest( NowPlaying , NowCommentWriting.Select(x => !x) ) .Select(x => x.All(y => y)) .ToReactiveProperty(PlayerWindowUIDispatcherScheduler) .AddTo(_CompositeDisposable); Suggestion = new ReactiveProperty <LiveSuggestion>(); HasSuggestion = Suggestion.Select(x => x != null) .ToReactiveProperty(); AutoHideDelayTime = HohoemaApp.UserSettings.PlayerSettings .ToReactivePropertyAsSynchronized(x => x.AutoHidePlayerControlUIPreventTime, PlayerWindowUIDispatcherScheduler) .AddTo(_CompositeDisposable); IsDisplayControlUI = HohoemaApp.Playlist.ToReactivePropertyAsSynchronized(x => x.IsDisplayPlayerControlUI); IsMuted = HohoemaApp.UserSettings.PlayerSettings .ToReactivePropertyAsSynchronized(x => x.IsMute, PlayerWindowUIDispatcherScheduler) .AddTo(_CompositeDisposable); IsMuted.Subscribe(isMuted => { MediaPlayer.IsMuted = isMuted; }) .AddTo(_CompositeDisposable); SoundVolume = HohoemaApp.UserSettings.PlayerSettings .ToReactivePropertyAsSynchronized(x => x.SoundVolume, PlayerWindowUIDispatcherScheduler) .AddTo(_CompositeDisposable); SoundVolume.Subscribe(volume => { MediaPlayer.Volume = volume; }) .AddTo(_CompositeDisposable); CommentUpdateInterval = HohoemaApp.UserSettings.PlayerSettings.ObserveProperty(x => x.CommentRenderingFPS) .Select(x => TimeSpan.FromSeconds(1.0 / x)) .ToReactiveProperty() .AddTo(_CompositeDisposable); RequestCommentDisplayDuration = HohoemaApp.UserSettings.PlayerSettings .ObserveProperty(x => x.CommentDisplayDuration) .ToReactiveProperty(PlayerWindowUIDispatcherScheduler) .AddTo(_CompositeDisposable); CommentFontScale = HohoemaApp.UserSettings.PlayerSettings .ObserveProperty(x => x.DefaultCommentFontScale) .ToReactiveProperty(PlayerWindowUIDispatcherScheduler) .AddTo(_CompositeDisposable); IsForceLandscape = new ReactiveProperty <bool>(PlayerWindowUIDispatcherScheduler, HohoemaApp.UserSettings.PlayerSettings.IsForceLandscape); IsStillLoggedInTwitter = new ReactiveProperty <bool>(!TwitterHelper.IsLoggedIn) .AddTo(_CompositeDisposable); }