Skip to content

peermusic/player-engine

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

player-engine

A simple wrapper around the HTML5 audio element.

Install

npm install https://github.com/peermusic/player-engine

For reference see the Browserify Handbook.

Usage

var engine = require('player-engine')

// Load a track to play into the engine
engine.load(url)

// Start the audio playback
engine.play()

// Stop the audio playback, an resets to the beginning of the track
engine.stop()

// Pauses the audio playback, can be resumed from the current state
engine.pause()

// Return the URL of the current track when the player is active else return "false"
engine.playing()

// Toggles the state of the player to playing/pause corresponding to the current state
engine.toggle()

// Sets volume to the given value (0-1)
// If no value is given gives back the current volume
engine.volume(volume)

// Sets the playback position
engine.seek(time)

// Triggers to update the current playback time
engine.on('timeupdate', function (progress) {
    // "progress" is a float with the current time (in seconds)
})

// Triggers when the currently played song ended
engine.on('ended', function () {
    // ...
})

About

A slim wrapper around the HTML5 audio element.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published