This package has been deprecated

Author message:

Work on this package has stopped in favour of solutions using Lavalink (i.e. lavacord package)

@favware/ytdl-prismplayer
TypeScript icon, indicating that this package has built-in type declarations

4.0.6 • Public • Published

DEPRECATED

Work on this package has stopped in favor of lavacord, a set of packages that aims to give great music support to your Discord bot using Lavalink. Furthermore, we also no longer support the development of Discord.JS in favor of @klasa/core


logo

@favware/ytdl-prismplayer

A ytdl-core wrapper focused on efficiency for use in Discord music bots.


Project Status

GitHub Coverage Status

Bundle Sizes

npm bundle size npm bundle size npm

Social Media and Donations

Join Discord server Twitter Follow Patreon Donate PayPal Donate


For compatible videos, this module uses prism-media to extract Opus or Vorbis audio from a stream without having to pipe it through FFmpeg first. This greatly reduces the processing power required, making playback smoother and allowing you to play over more connections simultaneously.

For videos where the required codec (webm + opus) isn't available, the module will fallback to using FFmpeg to encode the stream in Opus. Many new videos on YouTube are available in this codec so hopefully this isn't frequent.

Put simply, this module finds the most efficient way to extract a stream of Opus or Vorbis audio from a YouTube video.

Install

Install with yarn or npm:

yarn add @favware/ytdl-prismplayer ytdl-core prism-media

# npm install @favware/ytdl-prismplayer ytdl-core prism-media
# ytdl-core and prism-media are mandatory peer dependencies

Usage

Usage depends on the version of Discord.JS you are using, examples below. You can pass the exact same arguments as you would with the ytdl-core module, with the exception that you must await the function call.

Usage in Discord.js 11.x

const ytdl = require('@favware/ytdl-prismplayer');
// import ytdl from '@favware/ytdl-prismplayer'

async function play(connection, url) {
  connection.playOpusStream(await ytdl(url));
}

Usage in Discord.js 12.x / main

const ytdl = require('@favware/ytdl-prismplayer');
// import ytdl from '@favware/ytdl-prismplayer'

async function play(connection, url) {
  connection.play(await ytdl(url), {
    type: 'opus'
  });
}

// You can prefer vorbis instead of opus
async function play(connection, url) {
  connection.play(await ytdl(url, {}, { preferredFormat: 'vorbis' }), {
    type: 'opus'
  });
}

API Documentation

/@favware/ytdl-prismplayer/

    Package Sidebar

    Install

    npm i @favware/ytdl-prismplayer

    Weekly Downloads

    28

    Version

    4.0.6

    License

    MIT

    Unpacked Size

    27.3 kB

    Total Files

    8

    Last publish

    Collaborators

    • favna
    • favware-bot