void HandleLoginError(Exception e = null) { UpdateServiceStatus(); Context?.Dispose(); Context = new NiconicoContext(); LogInFailed?.Invoke(this, new NiconicoSessionLoginErrorEventArgs() { LoginFailedReason = InternetConnection.IsInternet() ? LoginFailedReason.ServiceNotAvailable : LoginFailedReason.OfflineNetwork , Exception = e, }); }
public async Task <PlayingOrchestrateResult> PreperePlayWithCache(VideoId videoId) { if (!InternetConnection.IsInternet()) { return(new PlayingOrchestrateResult(PlayingOrchestrateFailedReason.RequireNetworkConnection)); } var preparePlayVideo = await _nicoVideoSessionProvider.PreparePlayVideoAsync(videoId); var commentSessionProvider = preparePlayVideo; var nicoVideoDetails = preparePlayVideo?.GetVideoDetails(); return(new PlayingOrchestrateResult( new CachedVideoSessionProvider(_videoCacheManager.GetVideoCache(videoId), _niconicoSession), commentSessionProvider, nicoVideoDetails )); }
public async Task <PlayingOrchestrateResult> PreperePlayWithOnline(VideoId videoId) { if (!InternetConnection.IsInternet()) { return(new PlayingOrchestrateResult(PlayingOrchestrateFailedReason.RequireNetworkConnection)); } var preparePlayVideo = await _nicoVideoSessionProvider.PreparePlayVideoAsync(videoId); if (preparePlayVideo.IsSuccess) { return(new PlayingOrchestrateResult( preparePlayVideo, preparePlayVideo, preparePlayVideo.GetVideoDetails() )); } if (preparePlayVideo.Exception is not null and var ex) { return(new PlayingOrchestrateResult(ex)); }
public LatestSubscriptionVideosNotifier( IScheduler scheduler, SubscriptionManager subscriptionManager, NotificationService notificationService ) { _scheduler = scheduler; _subscriptionManager = subscriptionManager; _notificationService = notificationService; this._disposables.Add( Observable.FromEventPattern <SubscriptionFeedUpdateResult>( h => _subscriptionManager.Updated += h, h => _subscriptionManager.Updated -= h ) .Select(x => x.EventArgs) .Do(x => Results.Add(x)) .Throttle(TimeSpan.FromSeconds(5)) .SubscribeOn(_scheduler) .Subscribe(_ => { var items = Results.ToList(); Results.Clear(); // 失敗したアイテムの通知 if (!InternetConnection.IsInternet()) { foreach (var failedItem in items.Where(x => !x.IsSuccessed)) { _notificationService.ShowToast( $"Notification_FailedSubscriptionUpdate".Translate(), failedItem.Entity.Label, Microsoft.Toolkit.Uwp.Notifications.ToastDuration.Long, //luanchContent: SubscriptionManagementPageParam, toastButtons: new[] { new ToastButton(HohoemaPageType.SubscriptionManagement.Translate(), OpenSubscriptionManagementPageParam) } ); } } // 成功した購読ソースのラベルを連結してトーストコンテンツとして表示する var successedItems = items.Where(x => x.IsSuccessed && x.NewVideos.Any()); if (!successedItems.Any()) { return; } var newVideoOwnersText = string.Join(" - ", successedItems.Select(x => x.Entity.Label)); _notificationService.ShowToast( $"Notification_SuccessAddToWatchLaterWithAddedCount".Translate(successedItems.Sum(x => x.NewVideos.Count)), newVideoOwnersText, Microsoft.Toolkit.Uwp.Notifications.ToastDuration.Long, //luanchContent: PlayWithWatchAfterPlaylistParam, toastButtons: new[] { new ToastButton("WatchVideo".Translate(), PlayWithWatchAfterPlaylistParam), new ToastButton(HohoemaPageType.SubscriptionManagement.Translate(), OpenSubscriptionManagementPageParam) } ); })); }