_playTranscodable(media, options) { OpusEncoders.guaranteeOpusEngine(); this.killCurrentTranscoder(); const transcoder = this.prism.transcode({ type: 'ffmpeg', media, ffmpegArguments: ffmpegArguments.concat(['-ss', String(options.seek)]), }); /** * Emitted whenever an error occurs. * @event VoiceBroadcast#error * @param {Error} error The error that occurred */ transcoder.once('error', e => { if (this.listenerCount('error') > 0) this.emit('error', e); /** * Emitted whenever the VoiceBroadcast has any warnings. * @event VoiceBroadcast#warn * @param {string|Error} warning The warning that was raised */ else this.emit('warn', e); }); /** * Emitted once the broadcast (the audio stream) ends. * @event VoiceBroadcast#end */ transcoder.once('end', () => this.killCurrentTranscoder()); this.currentTranscoder = { transcoder, options, }; transcoder.output.once('readable', () => this._startPlaying()); return this; }
playUnknownStream(stream, options = {}) { this.destroy(); this.opusEncoder = OpusEncoders.fetch(options); const transcoder = this.prism.transcode({ type: 'ffmpeg', media: stream, ffmpegArguments: ffmpegArguments.concat(['-ss', String(options.seek || 0)]), }); this.destroyCurrentStream(); this.currentStream = { transcoder: transcoder, output: transcoder.output, input: stream, }; transcoder.on('error', e => { this.destroyCurrentStream(); if (this.listenerCount('error') > 0) this.emit('error', e); this.emit('warn', `prism transcoder error - ${e}`); }); return this.playPCMStream(transcoder.output, options, true); }