Fix livestreams

This commit is contained in:
Max Isom 2022-01-29 22:01:03 -05:00
parent af05210be4
commit c519a43620
No known key found for this signature in database
GPG key ID: 25C9B1A7F6798880
4 changed files with 33 additions and 24 deletions

View file

@ -5,6 +5,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [Unreleased]
### Fixed
- Playing livestreams now works again
## [0.5.1] - 2022-01-25
### Fixed

View file

@ -82,14 +82,14 @@
},
"dependencies": {
"@discordjs/opus": "^0.7.0",
"@discordjs/voice": "^0.7.5",
"@discordjs/voice": "^0.8.0",
"@prisma/client": "^3.7.0",
"@types/libsodium-wrappers": "^0.7.9",
"array-shuffle": "^3.0.0",
"debug": "^4.3.3",
"delay": "^5.0.0",
"discord-api-types": "^0.26.1",
"discord.js": "^13.5.0",
"discord.js": "^13.6.0",
"dotenv": "^8.5.1",
"execa": "^6.0.0",
"fluent-ffmpeg": "^2.1.2",

View file

@ -52,14 +52,11 @@ export default class {
}
async connect(channel: VoiceChannel): Promise<void> {
const conn = joinVoiceChannel({
this.voiceConnection = joinVoiceChannel({
channelId: channel.id,
guildId: channel.guild.id,
// @ts-expect-error (see https://github.com/discordjs/voice/issues/166)
adapterCreator: channel.guild.voiceAdapterCreator,
});
this.voiceConnection = conn;
}
disconnect(): void {
@ -94,7 +91,12 @@ export default class {
}
const stream = await this.getStream(currentSong.url, {seek: positionSeconds});
this.audioPlayer = createAudioPlayer();
this.audioPlayer = createAudioPlayer({
behaviors: {
// Needs to be somewhat high for livestreams
maxMissedFrames: 50,
},
});
this.voiceConnection.subscribe(this.audioPlayer);
this.audioPlayer.play(createAudioResource(stream, {
inputType: StreamType.WebmOpus,
@ -141,7 +143,12 @@ export default class {
try {
const stream = await this.getStream(currentSong.url);
this.audioPlayer = createAudioPlayer();
this.audioPlayer = createAudioPlayer({
behaviors: {
// Needs to be somewhat high for livestreams
maxMissedFrames: 50,
},
});
this.voiceConnection.subscribe(this.audioPlayer);
this.audioPlayer.play(createAudioResource(stream, {
inputType: StreamType.WebmOpus,

View file

@ -81,17 +81,17 @@
"@discordjs/node-pre-gyp" "^0.4.2"
node-addon-api "^4.2.0"
"@discordjs/voice@^0.7.5":
version "0.7.5"
resolved "https://registry.yarnpkg.com/@discordjs/voice/-/voice-0.7.5.tgz#c95bd4ecf73905f51990827df5209eb26472dbd5"
integrity sha512-lUk+CmIXNKslT6DkC9IF9rpsqhzlTiedauUCPBzepjd4XWxwBZiyVIzR6QpbAirxkAwCoAbbje+3Ho71PGLEAw==
"@discordjs/voice@^0.8.0":
version "0.8.0"
resolved "https://registry.yarnpkg.com/@discordjs/voice/-/voice-0.8.0.tgz#5d790fc25b883698f6eb7762efe1af00b6440947"
integrity sha512-o0JfVLMs3eLjUzPf6oxMydEeum40I7xzfUc66SLN+RrKpSAsTbngf5qnCF53nm+KDNSvrwg1AZqNm4LEAdxJIA==
dependencies:
"@types/ws" "^8.2.0"
discord-api-types "^0.24.0"
discord-api-types "^0.26.1"
prism-media "^1.3.2"
tiny-typed-emitter "^2.1.0"
tslib "^2.3.1"
ws "^8.2.3"
ws "^8.4.2"
"@eslint/eslintrc@^0.4.3":
version "0.4.3"
@ -1178,20 +1178,15 @@ dir-glob@^3.0.1:
dependencies:
path-type "^4.0.0"
discord-api-types@^0.24.0:
version "0.24.0"
resolved "https://registry.yarnpkg.com/discord-api-types/-/discord-api-types-0.24.0.tgz#9e429b8a1ddb4147134dfb3109093422de7ec549"
integrity sha512-X0uA2a92cRjowUEXpLZIHWl4jiX1NsUpDhcEOpa1/hpO1vkaokgZ8kkPtPih9hHth5UVQ3mHBu/PpB4qjyfJ4A==
discord-api-types@^0.26.0, discord-api-types@^0.26.1:
version "0.26.1"
resolved "https://registry.yarnpkg.com/discord-api-types/-/discord-api-types-0.26.1.tgz#726f766ddc37d60da95740991d22cb6ef2ed787b"
integrity sha512-T5PdMQ+Y1MEECYMV5wmyi9VEYPagEDEi4S0amgsszpWY0VB9JJ/hEvM6BgLhbdnKky4gfmZEXtEEtojN8ZKJQQ==
discord.js@^13.5.0:
version "13.5.0"
resolved "https://registry.yarnpkg.com/discord.js/-/discord.js-13.5.0.tgz#f9ca9e629f2de0fb138e8c916fa93e40d70631f5"
integrity sha512-K+ZcB0f+wA1ZzDhz3hlaAi4Ap7jSvVEUZ+U29T4DMoiNNUv22F4vu1byrOq8GyyLLDFiZ3iSudea0MvSHu3fQA==
discord.js@^13.6.0:
version "13.6.0"
resolved "https://registry.yarnpkg.com/discord.js/-/discord.js-13.6.0.tgz#d8a8a591dbf25cbcf9c783d5ddf22c4694860475"
integrity sha512-tXNR8zgsEPxPBvGk3AQjJ9ljIIC6/LOPjzKwpwz8Y1Q2X66Vi3ZqFgRHYwnHKC0jC0F+l4LzxlhmOJsBZDNg9g==
dependencies:
"@discordjs/builders" "^0.11.0"
"@discordjs/collection" "^0.4.0"
@ -3669,11 +3664,16 @@ write-file-atomic@^3.0.0:
signal-exit "^3.0.2"
typedarray-to-buffer "^3.1.5"
ws@^8.2.3, ws@^8.4.0:
ws@^8.4.0:
version "8.4.0"
resolved "https://registry.yarnpkg.com/ws/-/ws-8.4.0.tgz#f05e982a0a88c604080e8581576e2a063802bed6"
integrity sha512-IHVsKe2pjajSUIl4KYMQOdlyliovpEPquKkqbwswulszzI7r0SfQrxnXdWAEqOlDCLrVSJzo+O1hAwdog2sKSQ==
ws@^8.4.2:
version "8.4.2"
resolved "https://registry.yarnpkg.com/ws/-/ws-8.4.2.tgz#18e749868d8439f2268368829042894b6907aa0b"
integrity sha512-Kbk4Nxyq7/ZWqr/tarI9yIt/+iNNFOjBXEWgTb4ydaNHBNGgvf2QHbS9fdfsndfjFlFwEd4Al+mw83YkaD10ZA==
xbytes@^1.7.0:
version "1.7.0"
resolved "https://registry.yarnpkg.com/xbytes/-/xbytes-1.7.0.tgz#a44ca476af66c54e79f744756a035326c697bb8d"