internal void AddQueue(IVideoContent item) { _queueItems.RemoveOnScheduler(item); _queueItems.AddOnScheduler(item); RaisePropertyChanged(nameof(CanGoNext)); }
public async Task <bool> PlayWithoutPlaylistAsync(IVideoContent video, TimeSpan?initialPosition) { await PlayVideoOnSamePlaylistAsync_Internal(video, initialPosition); SetCurrentContent(video, 0); return(true); }
public async Task <bool> PlayOnCurrentPlaylistAsync(IVideoContent video) { await PlayVideoOnSamePlaylistAsync_Internal(video); SetCurrentContent(video, BufferedPlaylistItemsSource.IndexOf(video)); return(true); }
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); } } } }
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; } }
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); } }
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); } }
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); }
public static VideoPlayRequestMessage PlayPlaylist(IPlaylist playlist, IVideoContent playlistItem, TimeSpan?initialPosition = null) { return(new VideoPlayRequestMessage() { Playlist = playlist, PlaylistItem = playlistItem, Potision = initialPosition, }); }
public static VideoPlayRequestMessage PlayVideoWithQueue(IVideoContent playlistItem, TimeSpan?initialPosition = null) { return(new VideoPlayRequestMessage() { PlaylistItem = playlistItem, Potision = initialPosition, PlayWithQueue = true, }); }
public void AddPlaylistItem(IVideoContent item) { _playlistRepository.AddItem(Id, item.Id); ItemAdded?.Invoke(this, new LocalPlaylistItemAddedEventArgs() { PlaylistId = Id, AddedItems = new[] { item.Id } }); }
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); } }
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); }
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()) });
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); }
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);
public void StartSelection(IVideoContent firstSelectedItem = null) { if (!IsSelectionEnabled) { IsSelectionEnabled = true; if (firstSelectedItem != null) { SelectionItems.Add(firstSelectedItem); SelectionStarted?.Invoke(this, new RequestSelectionStartEventArgs() { FirstSelectedItem = firstSelectedItem }); } } }
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, }); }
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; } }
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); } }
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); }
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); }
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); } }
public Task <MylistItemAddedEventArgs> AddItem(IVideoContent video, string mylistComment = "") { return(AddItem(new[] { video }, mylistComment)); }
private int index = 0; // Указатель на элемент моего хранилища public ConcreteVideoIterator(IVideoContent videoContent) { this.videoContent = videoContent; }
protected override void Execute(IVideoContent content) { Execute(new[] { content }); }
protected virtual void Execute(IVideoContent content) { }
protected override void Execute(IVideoContent content) { _hohoemaPlaylist.AddWatchAfterPlaylist(content); }
protected override void Execute(IVideoContent content) { _playlist.AddItem(content.Id); }
public bool Equals(IVideoContent other) { return(Id == other.Id); }