Skip to content

Commit

Permalink
improved elapsed time display (most bugs fixed + new features)
Browse files Browse the repository at this point in the history
  • Loading branch information
ShadowLp174 committed Nov 14, 2023
1 parent eab40fd commit 7815497
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 26 deletions.
1 change: 1 addition & 0 deletions Player.js
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,7 @@ class RevoltPlayer extends EventEmitter {
}
}
}, { highWaterMark: 1048576 / 4 });
connection.media.once("startPlay", () => this.emit("streamStartPlay"));
connection.media.playStream(stream);
stream.once("data", () => this.startedPlaying = Date.now());
if (this.connection.preferredVolume) connection.media.setVolume(this.connection.preferredVolume);
Expand Down
7 changes: 6 additions & 1 deletion dashboard/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -400,6 +400,9 @@ class Dashboard {
const startPlayHandler = song => {
socket.emit("startplay", getSongData(song, player));
}
const streamStartPlayHandler = () => {
socket.emit("streamStartPlay");
}
const stopPlayHandler = () => {
socket.emit("stopplay");
}
Expand All @@ -418,13 +421,15 @@ class Dashboard {
socket.emit("queue", event);
}
player.on("startplay", startPlayHandler);
player.on("streamStartPlay", streamStartPlayHandler);
player.on("stopplay", stopPlayHandler);
player.on("volume", volumeHandler);
player.on("userupdate", userHandler);
player.on("playback", playbackHandler);
player.on("queue", queueHandler);
socket.on("disconnect", () => {
player.removeListener("startplay", startPlayHandler);
player.removeListener("streamStartPlay", streamStartPlayHandler);
player.removeListener("stopplay", stopPlayHandler);
player.removeListener("volume", volumeHandler);
player.removeListener("userupdate", userHandler);
Expand All @@ -438,7 +443,7 @@ class Dashboard {
socket.emit("info", {
connected: !!d.voice,
...currInfo(this.remix.client.channels.get(con.channelId)),
currSong: (!!d.voice) ? getSongData(d.player.data.current, d.player) : null,
currSong: (!!d.voice) ? {...getSongData(d.player.data.current, d.player), elapsedTime: d.player.player.seconds * 1000} : null,
currData: (!!d.voice) ? getPlayerData(d.player) : null
});
if (!!d.voice) subscribePlayer(d.player, socket);
Expand Down
1 change: 1 addition & 0 deletions dashboard/views/components/player.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -826,6 +826,7 @@
}
const resetTime = () => {
elapsedTime.innerText = "00:00";
duration.innerText = "00:00"
}
function update(vid) {
Expand Down
17 changes: 13 additions & 4 deletions dashboard/views/dashboard/index.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,10 @@
renderQueue(info.currData.queue);
}
if (info.channel) updateCDisplay(info);
if (info.currSong) update(info.currSong);
if (info.currSong) {
update(info.currSong);
if (info.currSong.elapsedTime > 0) startTime(info.currSong.elapsedTime);
}
if (info.channel) enablePlayer();
});
socket.on("joined", (data) => {
Expand Down Expand Up @@ -222,10 +225,16 @@
})
socket.on("left", () => { resetPlayer(); updateCDisplay({ channel: { name: "-" }, server: { name: "-" } }) });
socket.on("startplay", (vid) => {
startTime(0);
update(vid);
pauseTime(0);
resetTime();
update(vid)
});
socket.on("streamStartPlay", () => startTime(0))
socket.on("stopplay", () => {
pauseTime(0);
resetTime();
resetPlayer();
});
socket.on("stopplay", () => resetPlayer());
socket.on("volume", (v) => setVolume(v * 100));
socket.on("queue", (d) => updateQueue(d));
Expand Down
40 changes: 21 additions & 19 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"i18next-fs-backend": "^2.1.5",
"mysql": "^2.18.1",
"prism-media": "^1.3.5",
"revoice.js": "^0.1.754",
"revoice.js": "^0.1.7541",
"revolt-uploader": "^1.1.0",
"revolt.js": "npm:revolt.js-update@^7.0.0-beta.9-fix2.0",
"revoltbots.js": "^1.0.5",
Expand All @@ -28,7 +28,7 @@
"youtubei.js": "^5.1.0",
"yt-dlp-wrap-extended": "^2.3.15",
"yt-search": "^2.10.4",
"ytdl-core": "npm:@distube/ytdl-core@^4.11.9"
"ytdl-core": "npm:@distube/ytdl-core@^4.13.2"
},
"scripts": {
"dev": "node --inspect index.js --trace-warnings",
Expand Down

0 comments on commit 7815497

Please sign in to comment.