private async void Live2WebSocket_RecieveCurrentRoom(Live2CurrentRoomEventArgs e) { RoomName = e.RoomName; if (e.MessageServerType == "niwavided") { _NicoLiveCommentClient = new Niwavided.NiwavidedNicoLiveCommentClient( e.MessageServerUrl, e.ThreadId, this.HohoemaApp.LoginUserId.ToString(), HohoemaApp.NiconicoContext.HttpClient ); _NicoLiveCommentClient.Connected += _NicoLiveCommentClient_Connected; _NicoLiveCommentClient.Disconnected += _NicoLiveCommentClient_Disconnected; _NicoLiveCommentClient.CommentRecieved += _NicoLiveCommentClient_CommentRecieved; _NicoLiveCommentClient.CommentPosted += _NicoLiveCommentClient_CommentPosted; // コメントの受信処理と映像のオープンが被ると // 自動再生が失敗する?ので回避のため数秒遅らせる _NicoLiveCommentClient.Open(); await Task.Delay(500); await RefreshLeoPlayer(); } }
private void StartCommentClientConnection() { EndCommentClientConnection(); var baseTime = PlayerStatusResponse.Program.BaseAt; _NicoLiveCommentClient = new NicoLiveCommentClient(LiveId, PlayerStatusResponse.Program.CommentCount, PlayerStatusResponse.User.Id.ToString(), baseTime, PlayerStatusResponse.Comment.Server, HohoemaApp.NiconicoContext); _NicoLiveCommentClient.Connected += _NicoLiveCommentClient_Connected; _NicoLiveCommentClient.Disconnected += _NicoLiveCommentClient_Disconnected; _NicoLiveCommentClient.CommentRecieved += _NicoLiveCommentClient_CommentRecieved; _NicoLiveCommentClient.CommentPosted += _NicoLiveCommentClient_CommentPosted; _NicoLiveCommentClient.Open(); }
private async void Live2WebSocket_RecieveCurrentRoom(Live2CurrentRoomEventArgs e) { RoomName = e.RoomName; if (e.MessageServerType == "niwavided") { if (IsWatchWithTimeshift) { string waybackKey = await NicoLiveProvider.GetWaybackKeyAsync(e.ThreadId); _NicoLiveCommentClient = new Niwavided.NiwavidedNicoTimeshiftCommentClient( e.MessageServerUrl, e.ThreadId, NiconicoSession.UserIdString, waybackKey, LiveInfo.VideoInfo.Video.OpenTime.Value ); } else { _NicoLiveCommentClient = new Niwavided.NiwavidedNicoLiveCommentClient( e.MessageServerUrl, e.ThreadId, NiconicoSession.UserIdString, NiconicoSession.Context.HttpClient ); } _NicoLiveCommentClient.Connected += _NicoLiveCommentClient_Connected; _NicoLiveCommentClient.Disconnected += _NicoLiveCommentClient_Disconnected; _NicoLiveCommentClient.CommentRecieved += _NicoLiveCommentClient_CommentRecieved; _NicoLiveCommentClient.CommentPosted += _NicoLiveCommentClient_CommentPosted; // コメントの受信処理と映像のオープンが被ると // 自動再生が失敗する?ので回避のため数秒遅らせる // タイムシフトコメントはStartTimeへのシーク後に取得されることを想定して if (!(_NicoLiveCommentClient is Niwavided.NiwavidedNicoTimeshiftCommentClient)) { _NicoLiveCommentClient.Open(); await Task.Delay(Services.Helpers.DeviceTypeHelper.IsMobile? 3000 : 500); } } }