public override int GetHashCode() { int hash = 1; if (MessageType.Length != 0) { hash ^= MessageType.GetHashCode(); } if (CompressionType != global::AcFunDanmu.ZtLiveScMessage.Types.CompressionType.Unknown) { hash ^= CompressionType.GetHashCode(); } if (Payload.Length != 0) { hash ^= Payload.GetHashCode(); } if (LiveId.Length != 0) { hash ^= LiveId.GetHashCode(); } if (Ticket.Length != 0) { hash ^= Ticket.GetHashCode(); } if (ServerTimestampMs != 0L) { hash ^= ServerTimestampMs.GetHashCode(); } if (_unknownFields != null) { hash ^= _unknownFields.GetHashCode(); } return(hash); }
public static async Task<bool?> LoginAsync(bool logout) { try { var _Client = new Microsoft.Live.LiveAuthClient() { Theme = Microsoft.Live.ThemeType.Light }; if (logout && _Client.CanLogout) _Client.Logout(); LoginResult = await _Client.LoginAsync(new string[] { "wl.signin", "wl.basic", "wl.emails", "wl.skydrive", "wl.skydrive_update" }); if (LoginResult.Status != Microsoft.Live.LiveConnectSessionStatus.Connected) return false; Client = new Microsoft.Live.LiveConnectClient(LoginResult.Session); var _MeResult = (await Client.GetAsync("me")).Result; dynamic _PhotoResult = (await Client.GetAsync("me/picture")).Result; var _PhotoLocation = new Uri(_PhotoResult.location, UriKind.Absolute); User = new LiveId(_MeResult, _PhotoLocation); return true; } catch (Exception) { System.Diagnostics.Debugger.Break(); return null; } }
public override async Task OnNavigatedToAsync(INavigationParameters parameters) { await base.OnNavigatedToAsync(parameters); LiveId?maybeLiveId = null; if (parameters.TryGetValue("id", out string strLiveId)) { maybeLiveId = strLiveId; } else if (parameters.TryGetValue("id", out uint numberLiveId)) { maybeLiveId = numberLiveId; } else if (parameters.TryGetValue("id", out LiveId justLiveId)) { maybeLiveId = justLiveId; } if (maybeLiveId == null) { LiveId = new LiveId(); return; } LiveId = maybeLiveId.Value; await RefreshLiveInfoAsync(LiveId); }
private async Task <InAppNotificationPayload> SubmitLiveContentSuggestion(LiveId liveId) { var liveDesc = await NicoLiveProvider.GetLiveInfoAsync(liveId); if (liveDesc == null) { return(null); } var liveTitle = liveDesc.Data.Title; var payload = new InAppNotificationPayload() { Content = "InAppNotification_ContentDetectedFromClipboard".Translate(liveTitle), ShowDuration = DefaultNotificationShowDuration, IsShowDismissButton = true, Commands = { new InAppNotificationCommand() { Label = "WatchLiveStreaming".Translate(), Command = new RelayCommand(() => { _messenger.Send(new PlayerPlayLiveRequestMessage(new() { LiveId = liveId })); NotificationService.DismissInAppNotification(); }) },
public void LiveId_Equeal() { var idA = new LiveId(123456); var idB = new LiveId("lv123456"); Assert.AreEqual(idA, idB); }
public void LiveId_ToNiconicoId() { var idA = new LiveId(123456); NiconicoId idB = new LiveId("lv123456"); Assert.AreEqual(NiconicoIdType.Live, idB.IdType); Assert.AreEqual(idA, idB); }
private async Task <bool> DeleteReservation(LiveId liveId, string liveTitle) { if (string.IsNullOrEmpty(liveId)) { throw new ArgumentException(nameof(liveId)); } var niconicoSession = Microsoft.Toolkit.Mvvm.DependencyInjection.Ioc.Default.GetService <NiconicoSession>(); var hohoemaDialogService = Microsoft.Toolkit.Mvvm.DependencyInjection.Ioc.Default.GetService <DialogService>(); bool isDeleted = false; var token = await niconicoSession.ToolkitContext.Timeshift.GetReservationTokenAsync(); if (token == null) { return(isDeleted); } if (await hohoemaDialogService.ShowMessageDialog( $"{liveTitle}", "ConfirmDeleteTimeshift".Translate() , "DeleteTimeshift".Translate() , "Cancel".Translate() ) ) { await niconicoSession.ToolkitContext.Timeshift.DeleteTimeshiftReservationAsync(liveId, token); var deleteAfterReservations = await niconicoSession.ToolkitContext.Timeshift.GetTimeshiftReservationsDetailAsync(); isDeleted = !deleteAfterReservations.Data.Items.Any(x => liveId == x.LiveId); if (isDeleted) { // 削除成功 var notificationService = Microsoft.Toolkit.Mvvm.DependencyInjection.Ioc.Default.GetService <Services.NotificationService>(); notificationService.ShowLiteInAppNotification_Success("InAppNotification_DeletedTimeshift".Translate()); } else { // まだ存在するゾイ var notificationService = Microsoft.Toolkit.Mvvm.DependencyInjection.Ioc.Default.GetService <Services.NotificationService>(); notificationService.ShowLiteInAppNotification_Fail("InAppNotification_FailedDeleteTimeshift".Translate()); _logger.ZLogWarning("タイムシフト削除に失敗しました: {0}", liveId); } } return(isDeleted); }
private async Task <bool> AddReservationAsync(LiveId liveId, string liveTitle) { var niconicoSession = Microsoft.Toolkit.Mvvm.DependencyInjection.Ioc.Default.GetService <NiconicoSession>(); var hohoemaDialogService = Microsoft.Toolkit.Mvvm.DependencyInjection.Ioc.Default.GetService <DialogService>(); var result = await niconicoSession.ToolkitContext.Timeshift.ReserveTimeshiftAsync(liveId, overwrite : false); bool isAdded = false; if (result.IsCanOverwrite) { // 予約数が上限到達、他のタイムシフトを削除すれば予約可能 // いずれかの予約を削除するよう選択してもらう if (await hohoemaDialogService.ShowMessageDialog( "DialogContent_ConfirmTimeshiftReservationiOverwrite".Translate(result.Data.Overwrite.Title, liveTitle), "DialogTitle_ConfirmTimeshiftReservationiOverwrite".Translate(), "Overwrite".Translate(), "Cancel".Translate() )) { result = await niconicoSession.ToolkitContext.Timeshift.ReserveTimeshiftAsync(liveId, overwrite : true); } } if (result.IsSuccess) { // 予約できてるはず // LiveInfoのタイムシフト周りの情報と共に通知 var notificationService = Microsoft.Toolkit.Mvvm.DependencyInjection.Ioc.Default.GetService <Services.NotificationService>(); notificationService.ShowLiteInAppNotification_Success("InAppNotification_AddedTimeshiftWithTitle".Translate(liveTitle), TimeSpan.FromSeconds(3)); isAdded = true; } else if (result.IsCanOverwrite) { // 一つ前のダイアログで明示的的にキャンセルしてるはずなので特に通知を表示しない } else if (result.IsReservationDeuplicated) { var notificationService = Microsoft.Toolkit.Mvvm.DependencyInjection.Ioc.Default.GetService <Services.NotificationService>(); notificationService.ShowLiteInAppNotification_Success("InAppNotification_ExistTimeshift".Translate()); } else if (result.IsReservationExpired) { var notificationService = Microsoft.Toolkit.Mvvm.DependencyInjection.Ioc.Default.GetService <Services.NotificationService>(); notificationService.ShowLiteInAppNotification_Fail("InAppNotification_TimeshiftExpired".Translate()); } return(isAdded); }
async Task RefreshReservationInfo(LiveId liveId) { var reseevations = await NiconicoSession.ToolkitContext.Timeshift.GetTimeshiftReservationsDetailAsync(); var thisLiveReservation = reseevations.Data.Items.FirstOrDefault(x => x.LiveId == liveId); if (thisLiveReservation != null) { var timeshiftList = await NiconicoSession.ToolkitContext.Timeshift.GetTimeshiftReservationsAsync(); TimeshiftStatus = timeshiftList.Reservations.Items.FirstOrDefault(x => x.ProgramId == liveId).TimeshiftSetting.Status.ToString(); } _IsTsPreserved.Value = thisLiveReservation != null; }
private async Task RefreshTimeshiftProgram() { if (NiconicoSession.IsLoggedIn) { var timeshiftDetailsRes = await LoginUserLiveReservationProvider.GetReservtionsAsync(); foreach (var timeshift in timeshiftDetailsRes.ReservedProgram) { if (LiveId.EndsWith(timeshift.Id)) { _TimeshiftProgram = timeshift; } } } else { _TimeshiftProgram = null; } }
public override int GetHashCode() { int hash = 1; if (player_ != null) { hash ^= Player.GetHashCode(); } if (LiveId.Length != 0) { hash ^= LiveId.GetHashCode(); } if (EnableJumpPeerLiveRoom != false) { hash ^= EnableJumpPeerLiveRoom.GetHashCode(); } if (_unknownFields != null) { hash ^= _unknownFields.GetHashCode(); } return(hash); }
public override int GetHashCode() { int hash = 1; if (ChatId.Length != 0) { hash ^= ChatId.GetHashCode(); } if (LiveId.Length != 0) { hash ^= LiveId.GetHashCode(); } if (CallTimestampMs != 0L) { hash ^= CallTimestampMs.GetHashCode(); } if (_unknownFields != null) { hash ^= _unknownFields.GetHashCode(); } return(hash); }
public void PlayLiveVideoFromExternal(LiveId liveId) { _messenger.Send(new PlayerPlayLiveRequestMessage(new() { LiveId = liveId })); }
private async Task RefreshLiveInfoAsync() { IsLoadFailed.Value = false; LoadFailedMessage.Value = string.Empty; IsLiveInfoLoaded.Value = false; try { if (LiveId == null) { throw new Exception("Require LiveId in LiveInfomationPage navigation with (e.Parameter as string)"); } var liveInfoResponse = await NiconicoSession.Context.Live.GetLiveVideoInfoAsync(LiveId); if (!liveInfoResponse.IsOK) { throw new Exception("Live not found. LiveId is " + LiveId); } var liveInfo = liveInfoResponse.VideoInfo; { _LiveTags.Clear(); Func <string, LiveTagType, LiveTagViewModel> ConvertToLiveTagVM = (x, type) => new LiveTagViewModel() { Tag = x, Type = type }; var tags = new[] { liveInfo.Livetags.Category?.Tags.Select(x => ConvertToLiveTagVM(x, LiveTagType.Category)), liveInfo.Livetags.Locked?.Tags.Select(x => ConvertToLiveTagVM(x, LiveTagType.Locked)), liveInfo.Livetags.Free?.Tags.Select(x => ConvertToLiveTagVM(x, LiveTagType.Free)), } .SelectMany(x => x ?? Enumerable.Empty <LiveTagViewModel>()); foreach (var tag in tags) { _LiveTags.Add(tag); } RaisePropertyChanged(nameof(LiveTags)); } var reseevations = await NiconicoSession.Context.Live.GetReservationsInDetailAsync(); var thisLiveReservation = reseevations.ReservedProgram.FirstOrDefault(x => LiveId.EndsWith(x.Id)); if (thisLiveReservation != null) { var timeshiftList = await NiconicoSession.Context.Live.GetMyTimeshiftListAsync(); ExpiredTime = (timeshiftList.Items.FirstOrDefault(x => x.Id == LiveId)?.WatchTimeLimit ?? thisLiveReservation.ExpiredAt).LocalDateTime; } _IsTsPreserved.Value = thisLiveReservation != null; // タイムシフト視聴開始の判定処理のため_IsTsPreservedより後にLiveInfoを代入する LiveInfo = liveInfo; Community = LiveInfo.Community != null ? new LiveCommunityInfo() { Id = LiveInfo.Community.GlobalId, Label = LiveInfo.Community.Name } : null; } catch (Exception ex) { IsLoadFailed.Value = true; LoadFailedMessage.Value = ex.Message; } finally { IsLiveInfoLoaded.Value = true; } }
async Task RefreshLiveInfoAsync(LiveId liveId) { using var _ = await _UpdateLock.LockAsync(); IsLoadFailed.Value = false; LoadFailedMessage.Value = string.Empty; IsLiveInfoLoaded.Value = false; if (liveId == default(LiveId)) { throw new Models.Infrastructure.HohoemaExpception("Require LiveId in LiveInfomationPage navigation with (e.Parameter as string)"); } try { var programInfo = await NiconicoSession.ToolkitContext.Live.CasApi.GetLiveProgramAsync(liveId); if (programInfo.IsSuccess) { await RefreshLiveTagsAsync(programInfo.Data.Tags); await RefreshHtmlDescriptionAsync(programInfo.Data.Description); if (programInfo.Data.ProviderType == ProviderType.Community) { var communityInfo = await NiconicoSession.ToolkitContext.Community.GetCommunityInfoAsync(programInfo.Data.SocialGroupId); if (communityInfo.IsOK) { var community = communityInfo.Community; Community = new LiveCommunityInfo() { CommunityId = community.GlobalId, Name = community.Name, Thumbnail = community.ThumbnailNonSsl.OriginalString, Description = community.Description }; } else { Community = null; } } await RefreshReservationInfo(liveId); // タイムシフト視聴開始の判定処理のため_IsTsPreservedより後にLiveInfoを代入する LiveProgram = programInfo.Data; Live = new LiveData(programInfo.Data, Community?.Name); LiveId = liveId; } else { throw new Models.Infrastructure.HohoemaExpception("Live not found. LiveId is " + LiveId); } } catch (Exception ex) { IsLoadFailed.Value = true; LoadFailedMessage.Value = ex.Message; } finally { IsLiveInfoLoaded.Value = true; } }