async Task InitializeAsync() { using (await _updateLock.LockAsync()) { if (DataContext is Interfaces.IVideoContent video) { if (_context == video) { return; } IsInitialized = false; if (video is Interfaces.IVideoContentWritable videoContent) { await _videoInfoRepository.UpdateAsync(videoContent); } await Task.Delay(25); SubscriptionWatchedIfNotWatch(video); SubscribeCacheState(video); SubscribeNGVideoOwnerChanged(video); _context = video; IsInitialized = true; } } }
private void SubscribeNGVideoOwnerChanged(Interfaces.IVideoContent video) { UnsubscribeNGVideoOwnerChanged(); UpdateIsHidenVideoOwner(video); _ngSettings.NGVideoOwnerUserIds.CollectionChanged += NGVideoOwnerUserIds_CollectionChanged; }
void UpdateIsHidenVideoOwner(Interfaces.IVideoContent video) { if (video != null) { VideoHiddenInfo = _ngSettings.IsNgVideo(video); } else { VideoHiddenInfo = null; } }
private void SubscribeCacheState(Interfaces.IVideoContent video) { UnsubscribeCacheState(); // System.Diagnostics.Debug.Assert(DataContext != null); if (video != null) { _cacheManager.VideoCacheStateChanged += _cacheManager_VideoCacheStateChanged; var cacheRequest = _cacheManager.GetCacheRequest(video.Id); ResetCacheRequests(video, cacheRequest); } }
void SubscriptionWatchedIfNotWatch(Interfaces.IVideoContent video) { UnsubscriptionWatched(); if (video != null) { var watched = Database.VideoPlayedHistoryDb.IsVideoPlayed(video.Id); IsWatched = watched; if (!watched) { var eventAggregator = App.Current.Container.Resolve <IEventAggregator>(); var palyedEvent = eventAggregator.GetEvent <UseCase.Playlist.Events.VideoPlayedEvent>(); _watchedDisposable = palyedEvent.Subscribe(Watched, ThreadOption.UIThread); } } }
public NGResult IsNgVideo(Interfaces.IVideoContent info) { NGResult result = null; if (info.ProviderId != null) { result = IsNgVideoOwnerId(info.ProviderId); if (result != null) { return(result); } } result = IsNGVideoTitle(info.Label); if (result != null) { return(result); } return(result); }
void ResetCacheRequests(Interfaces.IVideoContent video, CacheRequest cacheRequest) { ClearHandleProgress(); _ = _dispatcher.RunAsync(CoreDispatcherPriority.Normal, async() => { // Note: 表示バグのワークアラウンドのため必要 CacheRequest = null; if (cacheRequest?.CacheState == NicoVideoCacheState.Downloading) { var progress = await _cacheManager.GetCacheProgress(video.Id); if (progress != null) { HandleProgress(progress); } cacheRequest = new CacheRequest(cacheRequest, cacheRequest.CacheState) { PriorityQuality = progress.Quality }; } if (cacheRequest?.CacheState == NicoVideoCacheState.Cached && cacheRequest.PriorityQuality == NicoVideoQuality.Unknown) { var cached = await _cacheManager.GetCachedAsync(video.Id); if (cached?.Any() ?? false) { cacheRequest = new CacheRequest(cacheRequest, cacheRequest.CacheState) { PriorityQuality = cached.First().Quality }; } } CacheRequest = cacheRequest; }); }