Usharp Video Sync

This commit is contained in:
Natsumi
2022-01-25 21:29:24 +13:00
parent 6e80180763
commit 6ae97e9d37
3 changed files with 42 additions and 8 deletions

View File

@@ -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
);
}
}

View File

@@ -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;