Koenie06 / Discord.js-Music

19 stars 13 forks source link

audio player frequently aborts #4

Closed KasperBosteels closed 2 years ago

KasperBosteels commented 2 years ago

audio player aborts at random times, during songs oh and any volume above 1 sounds distorted and is way too loud. error message:

AudioPlayerError: aborted
    at connResetException (node:internal/errors:691:14)        
    at TLSSocket.socketCloseListener (node:_http_client:407:19)
    at TLSSocket.emit (node:events:406:35)
    at node:net:672:12
    at TCP.done (node:_tls_wrap:580:7) {
  resource: AudioResource {
    playbackDuration: 194220,
    started: true,
    silenceRemaining: -1,
    edges: [ [Object], [Object], [Object] ],
    playStream: Encoder {
      _readableState: [ReadableState],
      _events: [Object: null prototype],
      _eventsCount: 5,
      _maxListeners: undefined,
      _writableState: [WritableState],
      allowHalfOpen: true,
      encoder: null,
      _options: [Object],
      _required: 3840,
      _buffer: null,
      [Symbol(kCapture)]: false,
      [Symbol(kCallback)]: [Function: bound onwrite]
    },
    metadata: null,
    silencePaddingFrames: 5,
    volume: VolumeTransformer {
      _readableState: [ReadableState],
      _events: [Object: null prototype],
      _eventsCount: 5,
      _maxListeners: undefined,
      _writableState: [WritableState],
      allowHalfOpen: true,
      _readInt: [Function (anonymous)],
      _writeInt: [Function (anonymous)],
      _bits: 16,
      _bytes: 2,
      _extremum: 32768,
      volume: 1,
      _chunk: null,
      [Symbol(kCapture)]: false,
      [Symbol(kCallback)]: [Function: bound onwrite]
    },
    encoder: Encoder {
      _readableState: [ReadableState],
      _events: [Object: null prototype],
      _eventsCount: 5,
      _maxListeners: undefined,
      _writableState: [WritableState],
      allowHalfOpen: true,
      encoder: null,
      _options: [Object],
      _required: 3840,
      _buffer: null,
      [Symbol(kCapture)]: false,
      [Symbol(kCallback)]: [Function: bound onwrite]
    },
    audioPlayer: AudioPlayer {
      _events: [Object: null prototype],
      _eventsCount: 2,
      _maxListeners: undefined,
      subscribers: [Array],
      _state: [Object],
      behaviors: [Object],
      debug: [Function (anonymous)],
      [Symbol(kCapture)]: false
    }
  }
}
KasperBosteels commented 2 years ago

this issue can be solved by going into the module and change some code in the index.js. the code i used:

 let resource = await createAudioResource(ytdl(data.queue[0].url, { filter: 'audioonly',highWaterMark:1<<25,quality:'highestaudio'}), { 
        inputType: StreamType.Arbitrary,
        inlineVolume: true,
    });

i added the highwatermark and the quality option.

volume issue: you can set the volume to a more bearable average when dividing it by 100 in the module (also index.js) at line 322

    fetchedData.resource.volume.setVolume(volume/100)
TheMindGold commented 2 years ago

this issue can be solved by going into the module and change some code in the index.js. the code i used:

 let resource = await createAudioResource(ytdl(data.queue[0].url, { filter: 'audioonly',highWaterMark:1<<25,quality:'highestaudio'}), { 
        inputType: StreamType.Arbitrary,
        inlineVolume: true,
    });

i added the highwatermark and the quality option.

volume issue: you can set the volume to a more bearable average when dividing it by 100 in the module (also index.js) at line 322

    fetchedData.resource.volume.setVolume(volume/100)

I added this in but still having the issue with it randomly aborting music

KasperBosteels commented 2 years ago

hmm maybe try lowering some of the setting a bit more if you read the ytdl-core documentation you can find some other setting to put there, hopefully that works for you