static LiveInfoListItemViewModel()
 {
     _logger                = Microsoft.Toolkit.Mvvm.DependencyInjection.Ioc.Default.GetService <ILoggerFactory>().CreateLogger <LiveInfoListItemViewModel>();
     PageManager            = Microsoft.Toolkit.Mvvm.DependencyInjection.Ioc.Default.GetService <PageManager>();
     OpenLiveContentCommand = Microsoft.Toolkit.Mvvm.DependencyInjection.Ioc.Default.GetService <OpenLiveContentCommand>();
     OpenShareUICommand     = Microsoft.Toolkit.Mvvm.DependencyInjection.Ioc.Default.GetService <OpenShareUICommand>();
     CopyToClipboardCommand = Microsoft.Toolkit.Mvvm.DependencyInjection.Ioc.Default.GetService <CopyToClipboardCommand>();
     CopyToClipboardWithShareTextCommand = Microsoft.Toolkit.Mvvm.DependencyInjection.Ioc.Default.GetService <CopyToClipboardWithShareTextCommand>();
 }
Esempio n. 2
0
 public VideoInfomationPageViewModel(
     ILoggerFactory loggerFactory,
     ApplicationLayoutManager applicationLayoutManager,
     AppearanceSettings appearanceSettings,
     VideoFilteringSettings ngSettings,
     NiconicoSession niconicoSession,
     LoginUserOwnedMylistManager userMylistManager,
     NicoVideoProvider nicoVideoProvider,
     LoginUserMylistProvider loginUserMylistProvider,
     SubscriptionManager subscriptionManager,
     NicoVideoSessionProvider nicoVideo,
     PageManager pageManager,
     Services.NotificationService notificationService,
     Services.DialogService dialogService,
     VideoPlayWithQueueCommand videoPlayWithQueueCommand,
     MylistAddItemCommand addMylistCommand,
     LocalPlaylistAddItemCommand localPlaylistAddItemCommand,
     AddSubscriptionCommand addSubscriptionCommand,
     OpenLinkCommand openLinkCommand,
     CopyToClipboardCommand copyToClipboardCommand,
     CopyToClipboardWithShareTextCommand copyToClipboardWithShareTextCommand,
     OpenShareUICommand openShareUICommand,
     CacheAddRequestCommand cacheAddRequestCommand,
     RecommendProvider recommendProvider,
     UserFollowProvider userFollowProvider,
     ChannelFollowProvider channelFollowProvider
     )
 {
     _logger = loggerFactory.CreateLogger <VideoInfomationPageViewModel>();
     ApplicationLayoutManager = applicationLayoutManager;
     AppearanceSettings       = appearanceSettings;
     NgSettings              = ngSettings;
     NiconicoSession         = niconicoSession;
     UserMylistManager       = userMylistManager;
     NicoVideoProvider       = nicoVideoProvider;
     LoginUserMylistProvider = loginUserMylistProvider;
     SubscriptionManager     = subscriptionManager;
     NicoVideo                           = nicoVideo;
     PageManager                         = pageManager;
     NotificationService                 = notificationService;
     DialogService                       = dialogService;
     VideoPlayWithQueueCommand           = videoPlayWithQueueCommand;
     AddMylistCommand                    = addMylistCommand;
     LocalPlaylistAddItemCommand         = localPlaylistAddItemCommand;
     AddSubscriptionCommand              = addSubscriptionCommand;
     OpenLinkCommand                     = openLinkCommand;
     CopyToClipboardCommand              = copyToClipboardCommand;
     CopyToClipboardWithShareTextCommand = copyToClipboardWithShareTextCommand;
     OpenShareUICommand                  = openShareUICommand;
     CacheAddRequestCommand              = cacheAddRequestCommand;
     _recommendProvider                  = recommendProvider;
     _userFollowProvider                 = userFollowProvider;
     _channelFollowProvider              = channelFollowProvider;
     NowLoading                          = new ReactiveProperty <bool>(false);
     IsLoadFailed                        = new ReactiveProperty <bool>(false);
 }
        // TODO: 視聴開始(会場後のみ、チャンネル会員限定やチケット必要な場合あり)
        // TODO: タイムシフト予約(tsがある場合のみ、会場前のみ、プレミアムの場合は会場後でも可)
        // TODO: 後からタイムシフト予約(プレミアムの場合のみ)
        // TODO: 配信説明
        // TODO: タグ
        // TODO: 配信者(チャンネルやコミュニティ)の概要説明
        // TODO: 配信者(チャンネルやコミュニティ)のフォロー
        // TODO: オススメ生放送(放送中、放送予定を明示)
        // TODO: ニコニコ市場
        // TODO: SNS共有


        // gateとwatchをどちらも扱った上でその差を意識させないように表現する

        // LiveInfo.Video.CurrentStatusは開演前、放送中は時間の経過によって変化する可能性がある

        public LiveInfomationPageViewModel(
            ApplicationLayoutManager applicationLayoutManager,
            AppearanceSettings appearanceSettings,
            PageManager pageManager,
            NiconicoSession niconicoSession,
            NicoLiveProvider nicoLiveProvider,
            DialogService dialogService,
            OpenLiveContentCommand openLiveContentCommand,
            OpenLinkCommand openLinkCommand,
            CopyToClipboardCommand copyToClipboardCommand,
            CopyToClipboardWithShareTextCommand copyToClipboardWithShareTextCommand
            )
        {
            ApplicationLayoutManager = applicationLayoutManager;
            _appearanceSettings      = appearanceSettings;
            PageManager            = pageManager;
            NiconicoSession        = niconicoSession;
            NicoLiveProvider       = nicoLiveProvider;
            HohoemaDialogService   = dialogService;
            OpenLiveContentCommand = openLiveContentCommand;
            OpenLinkCommand        = openLinkCommand;
            CopyToClipboardCommand = copyToClipboardCommand;
            CopyToClipboardWithShareTextCommand = copyToClipboardWithShareTextCommand;
            IsLoadFailed = new ReactiveProperty <bool>(false)
                           .AddTo(_CompositeDisposable);
            LoadFailedMessage = new ReactiveProperty <string>()
                                .AddTo(_CompositeDisposable);



            IsLiveIdAvairable = this.ObserveProperty(x => x.LiveId)
                                .Select(x => x != default(LiveId))
                                .ToReadOnlyReactiveProperty()
                                .AddTo(_CompositeDisposable);



            IsLoggedIn = NiconicoSession.ObserveProperty(x => x.IsLoggedIn)
                         .ToReadOnlyReactiveProperty()
                         .AddTo(_CompositeDisposable);

            IsPremiumAccount = NiconicoSession.ObserveProperty(x => x.IsPremiumAccount)
                               .ToReadOnlyReactiveProperty()
                               .AddTo(_CompositeDisposable);



            _IsTsPreserved = new ReactiveProperty <bool>(false)
                             .AddTo(_CompositeDisposable);

            LiveTags = new ReadOnlyObservableCollection <LiveTagViewModel>(_LiveTags);

            IchibaItems = new ReadOnlyObservableCollection <IchibaItem>(_IchibaItems);

            /*
             * ReccomendItems = _ReccomendItems.ToReadOnlyReactiveCollection(x =>
             * {
             *  var liveId = x.ProgramId;
             *  var liveInfoVM = new LiveInfoListItemViewModel(liveId);
             *  liveInfoVM.Setup(x);
             *
             *  var reserve = _Reservations?.ReservedProgram.FirstOrDefault(reservation => liveId == reservation.Id);
             *  if (reserve != null)
             *  {
             *      liveInfoVM.SetReservation(reserve);
             *  }
             *
             *  return liveInfoVM;
             * })
             *  .AddTo(_CompositeDisposable);
             */

            IsShowOpenLiveContentButton =
                new[]
            {
                this.ObserveProperty(x => LiveProgram).ToUnit(),
                NiconicoSession.ObserveProperty(x => x.IsLoggedIn).ToUnit(),
                _IsTsPreserved.ToUnit()
            }
            .Merge()
            .Select(x =>
            {
                if (LiveProgram == null)
                {
                    return(false);
                }

                if (NiconicoSession.IsPremiumAccount)
                {
                    if (LiveProgram.OnAirTime.BeginAt > DateTime.Now)
                    {
                        return(false);
                    }

                    return(LiveProgram.Timeshift.Enabled);
                }
                else
                {
                    // 一般アカウントは放送中のみ
                    if (LiveProgram.OnAirTime.BeginAt > DateTime.Now)
                    {
                        return(false);
                    }

                    if (_IsTsPreserved.Value)
                    {
                        return(true);
                    }

                    if (LiveProgram.OnAirTime.EndAt < DateTime.Now)
                    {
                        return(false);
                    }

                    return(true);
                }
            })
            .ToReadOnlyReactiveProperty()
            .AddTo(_CompositeDisposable);

            IsShowAddTimeshiftButton =
                new []
            {
                this.ObserveProperty(x => LiveProgram).ToUnit(),
                NiconicoSession.ObserveProperty(x => x.IsLoggedIn).ToUnit(),
                _IsTsPreserved.ToUnit()
            }
            .Merge()
            .Select(x =>
            {
                if (LiveProgram == null)
                {
                    return(false);
                }
                if (!LiveProgram.Timeshift.Enabled)
                {
                    return(false);
                }
                if (!NiconicoSession.IsLoggedIn)
                {
                    return(false);
                }

                if (!NiconicoSession.IsPremiumAccount)
                {
                    // 一般アカウントは放送開始の30分前からタイムシフトの登録はできなくなる
                    if ((LiveProgram.ShowTime.BeginAt - TimeSpan.FromMinutes(30)) < DateTime.Now)
                    {
                        return(false);
                    }
                }

                // 放送前、及び放送中はタイムシフトボタンを非表示…?
                // プレ垢なら常に表示しておいていいんじゃないの?
                //if (LiveProgram.ShowTime.EndAt > DateTime.Now) { return false; }

                // タイムシフト予約済み
                if (_IsTsPreserved.Value)
                {
                    return(false);
                }

                return(true);
            })
            .ToReadOnlyReactiveProperty()
            .AddTo(_CompositeDisposable);

            IsShowDeleteTimeshiftButton = _IsTsPreserved;
        }
        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();
        }