From c519a436200253636b37fa30768cfb2c3fdf0ed1 Mon Sep 17 00:00:00 2001 From: Max Isom Date: Sat, 29 Jan 2022 22:01:03 -0500 Subject: [PATCH 1/2] Fix livestreams --- CHANGELOG.md | 2 ++ package.json | 4 ++-- src/services/player.ts | 19 +++++++++++++------ yarn.lock | 32 ++++++++++++++++---------------- 4 files changed, 33 insertions(+), 24 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7330957..4622c48 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/package.json b/package.json index f98475b..399e7eb 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/src/services/player.ts b/src/services/player.ts index fc4b989..f46240a 100644 --- a/src/services/player.ts +++ b/src/services/player.ts @@ -52,14 +52,11 @@ export default class { } async connect(channel: VoiceChannel): Promise { - 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, diff --git a/yarn.lock b/yarn.lock index 2a960d1..c7afc71 100644 --- a/yarn.lock +++ b/yarn.lock @@ -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" From d0bb4fde27f4c44023845649d6e9ce6d09e66f24 Mon Sep 17 00:00:00 2001 From: Max Isom Date: Sat, 29 Jan 2022 22:01:32 -0500 Subject: [PATCH 2/2] Release 0.5.2 --- CHANGELOG.md | 5 ++++- package.json | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4622c48..7b6c7eb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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] + +## [0.5.2] - 2022-01-29 ### Fixed - Playing livestreams now works again @@ -52,7 +54,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added - Initial release -[Unreleased]: https://github.com/codetheweb/muse/compare/v0.5.1...HEAD +[Unreleased]: https://github.com/codetheweb/muse/compare/v0.5.2...HEAD +[0.5.2]: https://github.com/codetheweb/muse/compare/v0.5.1...v0.5.2 [0.5.1]: https://github.com/codetheweb/muse/compare/v0.5.0...v0.5.1 [0.5.0]: https://github.com/codetheweb/muse/compare/v0.4.0...v0.5.0 [0.4.0]: https://github.com/codetheweb/muse/compare/v0.3.2...v0.4.0 diff --git a/package.json b/package.json index 399e7eb..7782628 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "muse", - "version": "0.5.1", + "version": "0.5.2", "description": "🎧 a self-hosted Discord music bot that doesn't suck ", "exports": "./dist/src/index.js", "repository": "git@github.com:codetheweb/muse.git",