Skip to content

Play an MP3 from either a file or over HTTP through your speakers in Node.js

Notifications You must be signed in to change notification settings

isdampe/fat-mp3

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

fat-mp3

Play an MP3 from a file or directly from a HTTP stream through your speakers.

Basic usage

const fmp3 = require("fat-mp3");

// Play an MP3 from a file.
const filePlayer = new fmp3("test.mp3");
filePlayer.play();

// Pause it after ten seconds.
setTimeout(() => {
	player.pause(() => {
		console.log("Pause complete callback fired!");
	});
}, 10000);

// Play an MP3 file over HTTP.
const hPlayer = new fmp3("http://somesite.com/test.mp3");
hPlayer.play();

More detailed features

Begin buffering over HTTP in the background before playing

const fmp3 = require("fat-mp3");
const hPlayer = new fmp3("http://somesite.com/test.mp3");
hPlayer.on("error", (err) => {
	console.log("An error occurred.");
	console.error(err);
});
hPlayer.startBuffering();

// Let the player buffer for thirty seconds before playback begins.
setTimeout(() => {
	hPlayer.play();
}, 30000);

About

Play an MP3 from either a file or over HTTP through your speakers in Node.js

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published