1.0.0 • Published 3 years ago

gapless.js v1.0.0

Weekly downloads
2
License
MIT
Repository
github
Last release
3 years ago

gapless.js

gapless.js is a library for gapless audio playback. It is not intended to be a flawless solution for every use-case, but rather a balance between the needs of my use-case over at <Relisten.net>.

In short, it takes an array of audio tracks and utilizes HTML5 audio and the web audio API to enable gapless playback of individual tracks.

This library targets ES2018, which should be supported by all evergreen browsers: Safari v12+, Chrome 75+, Firefox 58+.

You can see a sample of the library in use currently at <Relisten.live> which is the not-yet-released beta of the next version of <Relisten.net>

Sample usage

    const player = new Gapless.Queue({
      tracks: [
        "http://phish.in/audio/000/012/321/12321.mp3",
        "http://phish.in/audio/000/012/322/12322.mp3",
        "http://phish.in/audio/000/012/323/12323.mp3",
        "http://phish.in/audio/000/012/324/12324.mp3"
      ],
      onProgress: function(track) {
        track && console.log(track.completeState);
      }
    });
    
    player.play();

Gapless.Queue Options

        tracks = [],
        onProgress,
        onEnded,
        onPlayNextTrack,
        onPlayPreviousTrack,
        onStartNewTrack,
        webAudioIsDisabled = false

API (subject to change)

// functions
player.togglePlayPause();   // toggle play/pause
player.playNext();          // play next track
player.playPrevious();      // play previous track
player.resetCurrentTrack(); // reset current track to 0
player.gotoTrack(idx, playImmediately); // jump to track by index and pass true to play immediately
player.disableWebAudio();   // disable gapless playback/web audio

// getters
player.currentTrack;        // returns current active track
player.nextTrack;           // returns next track

License

MIT - do as you please

2.2.3

3 years ago

2.2.2

3 years ago

2.2.1

3 years ago

2.2.0

3 years ago

2.1.0

3 years ago

1.0.0

6 years ago