コード例 #1
0
        internal void AddQueue(IVideoContent item)
        {
            _queueItems.RemoveOnScheduler(item);
            _queueItems.AddOnScheduler(item);

            RaisePropertyChanged(nameof(CanGoNext));
        }
コード例 #2
0
        public async Task <bool> PlayWithoutPlaylistAsync(IVideoContent video, TimeSpan?initialPosition)
        {
            await PlayVideoOnSamePlaylistAsync_Internal(video, initialPosition);

            SetCurrentContent(video, 0);
            return(true);
        }
コード例 #3
0
        public async Task <bool> PlayOnCurrentPlaylistAsync(IVideoContent video)
        {
            await PlayVideoOnSamePlaylistAsync_Internal(video);

            SetCurrentContent(video, BufferedPlaylistItemsSource.IndexOf(video));
            return(true);
        }
コード例 #4
0
        protected override void Execute(IVideoContent content)
        {
            bool isQueueEmpty = !_hohoemaPlaylist.QueuePlaylist.Any();

            _hohoemaPlaylist.AddQueue(content);

            if (isQueueEmpty)
            {
                var displayViewMode = NicoVideoPlayer.VideoPlayRequestBridgeToPlayer.ReadDisplayMode();
                if (displayViewMode == NicoVideoPlayer.PlayerDisplayView.SecondaryView)
                {
                    if (!_scondaryViewPlayerManager.IsShowSecondaryView)
                    {
                        _scondaryViewPlayerManager.OnceSurpressActivation();

                        _hohoemaPlaylist.Play(content);
                    }
                }
                else
                {
                    if (_primaryViewPlayerManager.DisplayMode == PrimaryPlayerDisplayMode.Close)
                    {
                        _primaryViewPlayerManager.ShowWithWindowInWindow();
                        _hohoemaPlaylist.Play(content);
                    }
                }
            }
        }
コード例 #5
0
        public async Task <bool> RemoveHistoryAsync(IVideoContent watchHistory)
        {
            try
            {
                var result = await _LoginUserVideoWatchHistoryProvider.RemoveHistoryAsync(watchHistory.VideoId);

                if (result)
                {
                    WatchHistoryRemoved?.Invoke(this, new WatchHistoryRemovedEventArgs()
                    {
                        VideoId = watchHistory.VideoId
                    });

                    _notificationService.ShowLiteInAppNotification_Success("VideoHistory_DeleteOne_Success".Translate());
                }
                else
                {
                    _notificationService.ShowLiteInAppNotification_Success("VideoHistory_DeleteOne_Fail".Translate());
                }

                return(result);
            }
            catch
            {
                _notificationService.ShowLiteInAppNotification_Success("VideoHistory_DeleteOne_Fail".Translate());
                throw;
            }
        }
コード例 #6
0
        internal async void SetCurrent(IVideoContent item)
        {
            if (item == null)
            {
                throw new Exception();
            }

            using (var releaser = await _PlaylistUpdateLock.LockAsync())
            {
                // GoNext/GoBack内でCurrentが既に変更済みの場合はスキップ
                // Playlist外から直接PlaylistItemが変更された場合にのみ
                // 現在再生位置の更新を行う
                Current = item;
                if (_items.Any())
                {
                    CurrentIndex = _items.IndexOf(Current);
                }
                else
                {
                    CurrentIndex = 0;
                }

                PlayRequested?.Invoke(this, Current);
            }
        }
コード例 #7
0
        protected override async void Execute(IVideoContent content)
        {
            var status = _videoCacheManager.GetVideoCacheStatus(content.VideoId);

            if (status is null)
            {
                return;
            }

            if (status is VideoCacheStatus.Completed)
            {
                var confirmed = await _dialogService.ShowMessageDialog(
                    "ConfirmCacheRemoveContent".Translate(content.Title),
                    $"ConfirmCacheRemoveTitle".Translate(),
                    acceptButtonText : "Delete".Translate(),
                    "Cancel".Translate()
                    );

                if (confirmed)
                {
                    await _videoCacheManager.CancelCacheRequestAsync(content.VideoId);
                }
            }
            else
            {
                await _videoCacheManager.CancelCacheRequestAsync(content.VideoId);
            }
        }
コード例 #8
0
        protected override void Execute(IVideoContent content)
        {
            var currentMethod = System.Reflection.MethodBase.GetCurrentMethod();

            //Microsoft.AppCenter.Analytics.Analytics.TrackEvent($"{currentMethod.DeclaringType.Name}#{currentMethod.Name}");

            _ = _videoCacheManager.PushCacheRequestAsync(content.VideoId, VideoQuality);
        }
コード例 #9
0
 public static VideoPlayRequestMessage PlayPlaylist(IPlaylist playlist, IVideoContent playlistItem, TimeSpan?initialPosition = null)
 {
     return(new VideoPlayRequestMessage()
     {
         Playlist = playlist,
         PlaylistItem = playlistItem,
         Potision = initialPosition,
     });
 }
コード例 #10
0
 public static VideoPlayRequestMessage PlayVideoWithQueue(IVideoContent playlistItem, TimeSpan?initialPosition = null)
 {
     return(new VideoPlayRequestMessage()
     {
         PlaylistItem = playlistItem,
         Potision = initialPosition,
         PlayWithQueue = true,
     });
 }
コード例 #11
0
 public void AddPlaylistItem(IVideoContent item)
 {
     _playlistRepository.AddItem(Id, item.Id);
     ItemAdded?.Invoke(this, new LocalPlaylistItemAddedEventArgs()
     {
         PlaylistId = Id,
         AddedItems = new[] { item.Id }
     });
 }
コード例 #12
0
        protected override void Execute(IVideoContent content)
        {
            var currentMethod = System.Reflection.MethodBase.GetCurrentMethod();

            //Microsoft.AppCenter.Analytics.Analytics.TrackEvent($"{currentMethod.DeclaringType.Name}#{currentMethod.Name}");

            if (content is IPlaylistItemPlayable playableItem)
            {
                _playlist.RemovePlaylistItem(playableItem.PlaylistItemToken);
            }
        }
コード例 #13
0
ファイル: HohoemaPlaylist.cs プロジェクト: TaoziDB/Hohoema
        public void PlayVideo(IVideoContent video)
        {
            if (!(NiconicoRegex.IsVideoId(video.Id) || video.Id.All(x => '0' <= x && x <= '9')))
            {
                return;
            }

            var item = DefaultPlaylist.PlaylistItems.FirstOrDefault(x => x.Type == PlaylistItemType.Video && x.ContentId == video.Id)
                       ?? DefaultPlaylist.AddVideo(video.Id, video.Label, ContentInsertPosition.Head);

            Play(item);
        }
コード例 #14
0
 public static string GetLabel(this INiconicoObject obj)
 {
     return(obj switch
     {
         IVideoContent video => video.Title,
         ILiveContent live => live.Title,
         ICommunity community => community.Name,
         IChannel channel => channel.Name,
         IMylist mylist => mylist.Name,
         ITag tag => tag.Tag,
         IUser user => user.Nickname,
         _ => throw new NotSupportedException(obj.ToString())
     });
コード例 #15
0
        public bool RemovePlaylistItem(IVideoContent item)
        {
            var result = _playlistRepository.DeleteItem(Id, item.Id);

            if (result)
            {
                ItemRemoved?.Invoke(this, new LocalPlaylistItemRemovedEventArgs()
                {
                    PlaylistId   = Id,
                    RemovedItems = new[] { item.Id }
                });
            }
            return(result);
        }
コード例 #16
0
        private async Task <bool> UpdatePlayingMediaAsync(IVideoContent item, TimeSpan?startPosition)
        {
            Guard.IsNotNull(item, nameof(item));

            try
            {
                var result = await _videoStreamingOriginOrchestrator.CreatePlayingOrchestrateResultAsync(item.VideoId);

                CurrentPlayingSession = result;
                if (!result.IsSuccess)
                {
                    _messenger.Send(new PlaybackFailedMessage(new(this, CurrentPlaylistId, item.VideoId, result.PlayingOrchestrateFailedReason)));
                    return(false);
                }

                var qualityEntity = AvailableQualities.FirstOrDefault(x => x.Quality == _playerSettings.DefaultVideoQuality);
                if (qualityEntity?.IsAvailable is null or false)
                {
                    qualityEntity = AvailableQualities.SkipWhile(x => !x.IsAvailable).First();
                }

                var videoSession = await result.VideoSessionProvider.CreateVideoSessionAsync(qualityEntity.Quality);

                _videoSessionDisposable = videoSession;
                await videoSession.StartPlayback(_mediaPlayer, startPosition ?? TimeSpan.Zero);

                CurrentQuality = AvailableQualities.First(x => x.Quality == videoSession.Quality);
                Guard.IsNotNull(_mediaPlayer.PlaybackSession, nameof(_mediaPlayer.PlaybackSession));


                OnPropertyChanged(nameof(AvailableQualities));

                NowPlayingWithCache = videoSession is CachedVideoStreamingSession;
                _soundVolumeManager.LoudnessCorrectionValue = CurrentPlayingSession.VideoDetails.LoudnessCorrectionValue;

                // メディア再生成功時のメッセージを飛ばす
                _messenger.Send(new PlaybackStartedMessage(new(this, CurrentPlaylistId, item.VideoId, videoSession.Quality, _mediaPlayer.PlaybackSession)));

                _mediaPlayer.PlaybackSession.PlaybackStateChanged += PlaybackSession_PlaybackStateChanged;

                _mediaPlayer.CommandManager.IsEnabled = false;

                await _dispatcherQueue.EnqueueAsync(async() =>
                {
                    _smtc.IsEnabled            = true;
                    _smtc.IsPauseEnabled       = true;
                    _smtc.IsPlayEnabled        = true;
                    _smtc.IsStopEnabled        = true;
                    _smtc.IsFastForwardEnabled = true;
                    _smtc.IsNextEnabled        = await CanGoNextAsync_Internal(default);
コード例 #17
0
        public void StartSelection(IVideoContent firstSelectedItem = null)
        {
            if (!IsSelectionEnabled)
            {
                IsSelectionEnabled = true;

                if (firstSelectedItem != null)
                {
                    SelectionItems.Add(firstSelectedItem);
                    SelectionStarted?.Invoke(this, new RequestSelectionStartEventArgs()
                    {
                        FirstSelectedItem = firstSelectedItem
                    });
                }
            }
        }
コード例 #18
0
        public void PlayVideo(IVideoContent video)
        {
            if (!(NiconicoRegex.IsVideoId(video.Id) || video.Id.All(x => '0' <= x && x <= '9')))
            {
                return;
            }

            DefaultPlaylist.AddMylistItem(video.Id, ContentInsertPosition.Head);

            Play(new QualityVideoPlaylistItem()
            {
                ContentId = video.Id,
                Owner     = video.OnwerPlaylist ?? DefaultPlaylist,
                Title     = video.Label,
                Type      = PlaylistItemType.Video,
            });
        }
コード例 #19
0
        protected override async Task PlayVideoOnSamePlaylistAsync_Internal(IVideoContent item, TimeSpan?startPosition = null)
        {
            Guard.IsNotNull(item, nameof(item));
            //Guard.IsNotNull(CurrentPlaylistId, nameof(CurrentPlaylistId));
            Guard.IsFalse(item.VideoId == default(VideoId), "Not contain playable VideoId or PlaylistId");

            if (startPosition == null &&
                CurrentPlaylistItem?.VideoId == item.VideoId)
            {
                startPosition = _mediaPlayer.PlaybackSession?.Position;
            }

            StopPlaybackMedia();

            if (false == await UpdatePlayingMediaAsync(item, startPosition))
            {
                return;
            }
        }
コード例 #20
0
ファイル: HohoemaPlaylist.cs プロジェクト: TaoziDB/Hohoema
        public void PlayVideoWithPlaylist(IVideoContent video)
        {
            if (!(NiconicoRegex.IsVideoId(video.Id) || video.Id.All(x => '0' <= x && x <= '9')))
            {
                return;
            }

            if (video.Playlist != null)
            {
                var playlistItem = video.Playlist.PlaylistItems.FirstOrDefault(x => x.ContentId == video.Id);
                if (playlistItem != null)
                {
                    Play(playlistItem);
                }
            }
            else
            {
                var newItem = DefaultPlaylist.AddVideo(video.Id, video.Label, ContentInsertPosition.Head);
                Play(newItem);
            }
        }
コード例 #21
0
ファイル: NGSettings.cs プロジェクト: tor4kichi/Hohoema
        public NGResult IsNgVideo(IVideoContent info)
        {
            NGResult result = null;

            if (info is IVideoContentProvider provider && provider.ProviderId != null)
            {
                result = IsNgVideoOwnerId(provider.ProviderId);
                if (result != null)
                {
                    return(result);
                }
            }

            result = IsNGVideoTitle(info.Title);
            if (result != null)
            {
                return(result);
            }

            return(result);
        }
コード例 #22
0
        public bool TryGetHiddenReason(IVideoContent video, out FilteredResult result)
        {
            if (TryGetFilteredResultVideoId(video.VideoId, out var condi))
            {
                result = new FilteredResult()
                {
                    FilteredReason  = FilteredReason.VideoId,
                    FilterCondition = condi.Description,
                };

                return(true);
            }
            else if (video is IVideoContentProvider provider && provider.ProviderId != null && TryGetFilteredResultVideoOwnerId(provider.ProviderId, out var user))
            {
                result = new FilteredResult()
                {
                    FilteredReason  = FilteredReason.UserId,
                    FilterCondition = user.Description,
                };

                return(true);
            }
コード例 #23
0
        protected override async void Execute(IVideoContent content)
        {
            var video         = Database.NicoVideoDb.Get(content.Id);
            var cacheRequests = await VideoCacheManager.GetCachedAsync(content.Id);

            if (cacheRequests.Any())
            {
                var confirmed = await DialogService.ShowMessageDialog(
                    "ConfirmCacheRemoveContent".Translate(content.Label),
                    $"ConfirmCacheRemoveTitle".Translate(),
                    acceptButtonText : "Delete".Translate(),
                    "Cancel".Translate()
                    );

                if (confirmed)
                {
                    await VideoCacheManager.CancelCacheRequest(content.Id);
                }
            }
            else
            {
                await VideoCacheManager.CancelCacheRequest(content.Id);
            }
        }
コード例 #24
0
 public Task <MylistItemAddedEventArgs> AddItem(IVideoContent video, string mylistComment = "")
 {
     return(AddItem(new[] { video }, mylistComment));
 }
コード例 #25
0
        private int index = 0;                       // Указатель на элемент моего хранилища

        public ConcreteVideoIterator(IVideoContent videoContent)
        {
            this.videoContent = videoContent;
        }
コード例 #26
0
 protected override void Execute(IVideoContent content)
 {
     Execute(new[] { content });
 }
コード例 #27
0
 protected virtual void Execute(IVideoContent content)
 {
 }
コード例 #28
0
 protected override void Execute(IVideoContent content)
 {
     _hohoemaPlaylist.AddWatchAfterPlaylist(content);
 }
コード例 #29
0
 protected override void Execute(IVideoContent content)
 {
     _playlist.AddItem(content.Id);
 }
コード例 #30
0
 public bool Equals(IVideoContent other)
 {
     return(Id == other.Id);
 }