diff --git a/LogWatcher.cs b/LogWatcher.cs index 744b2a79..86270709 100644 --- a/LogWatcher.cs +++ b/LogWatcher.cs @@ -221,6 +221,7 @@ namespace VRCX ParseLogVideoError(fileInfo, logContext, line, offset) == true || ParseLogVideoChange(fileInfo, logContext, line, offset) == true || ParseLogUsharpVideoPlay(fileInfo, logContext, line, offset) == true || + ParseLogUsharpVideoSync(fileInfo, logContext, line, offset) == true || ParseLogWorldVRCX(fileInfo, logContext, line, offset) == true || ParseLogPhotonId(fileInfo, logContext, line, offset) == true) { @@ -639,6 +640,26 @@ namespace VRCX return true; } + private bool ParseLogUsharpVideoSync(FileInfo fileInfo, LogContext logContext, string line, int offset) + { + // 2022.01.16 05:20:23 Log - [USharpVideo] Syncing video to 2.52 + + if (string.Compare(line, offset, "[USharpVideo] Syncing video to ", 0, 31, StringComparison.Ordinal) != 0) + return false; + + var data = line.Substring(offset + 31); + + AppendLog(new[] + { + fileInfo.Name, + ConvertLogTimeToISO8601(line), + "video-sync", + data + }); + + return true; + } + private bool ParseLogNotification(FileInfo fileInfo, LogContext logContext, string line, int offset) { // 2021.01.03 05:48:58 Log - [API] Received Notification: < Notification from username:pypy, sender user id:usr_4f76a584-9d4b-46f6-8209-8305eb683661 to of type: friendRequest, id: not_3a8f66eb-613c-4351-bee3-9980e6b5652c, created at: 01/14/2021 15:38:40 UTC, details: {{}}, type:friendRequest, m seen:False, message: ""> received at 01/02/2021 16:48:58 UTC diff --git a/html/src/app.js b/html/src/app.js index 52362421..0fac3213 100644 --- a/html/src/app.js +++ b/html/src/app.js @@ -8008,6 +8008,12 @@ speechSynthesis.getVoices(); this.lastVideoUrl = gameLog.videoUrl; this.addGameLogVideo(gameLog, location, userId); return; + case 'video-sync': + var timestamp = gameLog.timestamp.replace(/,/g, ''); + if (this.nowPlaying.playing) { + this.nowPlaying.offset = parseInt(timestamp, 10); + } + return; case 'api-request': var bias = Date.parse(gameLog.dt) + 60 * 1000; if (!this.isGameRunning || bias < Date.now()) { @@ -9198,10 +9204,6 @@ speechSynthesis.getVoices(); videoLength = this.convertYoutubeTime( data.items[0].contentDetails.duration ); - if (videoLength) { - // add loading time - videoLength += 15; - } } } } catch { @@ -9395,6 +9397,7 @@ speechSynthesis.getVoices(); name: '', length: 0, startTime: 0, + offset: 0, elapsed: 0, percentage: 0, remainingText: '', @@ -9407,6 +9410,7 @@ speechSynthesis.getVoices(); name: '', length: 0, startTime: 0, + offset: 0, elapsed: 0, percentage: 0, remainingText: '', @@ -9430,7 +9434,8 @@ speechSynthesis.getVoices(); url: ctx.videoUrl, name, length: ctx.videoLength, - startTime: Date.parse(ctx.created_at) / 1000 - ctx.videoPos, + startTime: Date.parse(ctx.created_at) / 1000, + offset: ctx.videoPos, elapsed: 0, percentage: 0, remainingText: '' @@ -9439,7 +9444,8 @@ speechSynthesis.getVoices(); this.nowPlaying = { ...this.nowPlaying, length: ctx.videoLength, - startTime: Date.parse(ctx.created_at) / 1000 - ctx.videoPos, + startTime: Date.parse(ctx.created_at) / 1000, + offset: ctx.videoPos, elapsed: 0, percentage: 0, remainingText: '' @@ -9459,7 +9465,7 @@ speechSynthesis.getVoices(); return; } var now = Date.now() / 1000; - np.elapsed = Math.round((now - np.startTime) * 10) / 10; + np.elapsed = Math.round((now - np.startTime + np.offset) * 10) / 10; if (np.elapsed >= np.length) { this.clearNowPlaying(); return; @@ -9647,7 +9653,10 @@ speechSynthesis.getVoices(); if (this.nowPlaying.playing) { Discord.SetTimestamps( Date.now(), - (this.nowPlaying.startTime + this.nowPlaying.length) * 1000 + (this.nowPlaying.startTime - + this.nowPlaying.offset + + this.nowPlaying.length) * + 1000 ); } } diff --git a/html/src/service/gamelog.js b/html/src/service/gamelog.js index 159afd1a..c142c4dc 100644 --- a/html/src/service/gamelog.js +++ b/html/src/service/gamelog.js @@ -42,6 +42,10 @@ class GameLogService { gameLog.displayName = args[1]; break; + case 'video-sync': + gameLog.timestamp = args[0]; + break; + case 'vrcx': gameLog.data = args[0]; break;