Playing Local Files
Learn how to play local files using discord-player
Wouldn't it be nice if you could play local files? Well, Discord Player got you covered. Discord Player natively supports local file playback with the help of Attachment
extractor. Discord Player wont load file from your system unless you explicitly tell it to do so. Discord Player does this to prevent any unwanted security issues that may arise from loading files from your system. In conclusion, you can play local files by explicitly setting QueryType.FILE
as the search engine.
How does it work?
- Discord Player will validate your search query against the registered extractors. When using the default extractors provided by discord-player, only
AttachmentExtractor
will respond to your query if your search engine value is set toQueryType.FILE
. - If the extractor responds to your query, Discord Player will use it to get track metadata.
AttachmentExtractor
will search for the file in your system and return the metadata if it finds the file.- If the file is found, Discord Player will again run validation against it to make sure the file is playable.
- If the file is playable, Discord Player will load the file and play it.
Example
This does not show the metadata of the track you are playing. In order to add support for the metadata, you need to install mediaplex on your system.
Discord Player will automatically attempt to parse file metadata using mediaplex. The metadata includes title of the track, author of the track, duration of the track, etc.