Giter Club home page Giter Club logo

node-ghettoblaster's Introduction

Node Ghettoblaster

A Node.js music player. It uses mplayer in slave mode and send controls via the stdin.

##Usage

Install the module (You must have mplayer on your system)

npm install node-ghettoblaster

Create objects with the file you want to be played as argument.

	var GBlaster = require('node-ghettoblaster');

	var player1 = new GBlaster('/home/platypus/Music/Eminem - Rap God (explicit).mp3');
    var player2 = new GBlaster('http://mysongwebsite/song/Sound%20of%20Silence.mp3');

##Available methods

###play

The first method to call after instanciation (Calling other ones will do nothing ;) ). It will start playing if called the first time and resume if the music was paused before. You can specify the volume and the number of time the music will be played with the volume and loop options

	player.play();
    player.play({volume: 50});
    player.play({volume: 50,
    			loop: 10});

###stop

This method will stop the played file.

	player.stop();

###pause

This one will pause if playing.

	player.pause();

###resume

This one will resume if paused.

	player.pause();

###toggle

This one will toggle pause.

	player.toggle();

###mute

The method to toggle mute

	player.mute();

###setVolume

This method is used to set the volume. It takes one parameter, the volume value that can go from 1 to 100.

	player.setVolume(52);

###seek

This method is used to navigate in the playing file. It take one parameter, the seek value in seconds that goes from 0 to the end of the file. This value is absolute.

	player.seek(50);    //will go to 50 seconds

###setLoop

This will set the number of times to replay the file. The parameter is the number of times, -1 is forever.

	player.setLoop(20);

###setSpeed

This will set the playing speed. It takes one parameter, the speed. 1 is the default speed.

	player.setSpeed(0.5);    //will play the file 0.5x slower
    player.setSpeed(20);    //will play the file 20x faster

###getTimeLength

Returns the length of the file in seconds. It needs a callback.

	player.getTimeLength(function(length){
    	console.log(length);
    });

###getTimePosition

Returns the elapsed play time in seconds. It needs a callback.

	player.getTimePosition(function(elapsedTime){
    	console.log(elapsedTime);
    });

##Events

I won't explain those events, the names are quite explicit

  • play
  • paused
  • resumed
  • stopped
  • muted
  • end
  • error

Do whatever you want with this module, I don't care.

node-ghettoblaster's People

Contributors

matejc avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.