Skip to content

jgeurts/gapless.js

 
 

Repository files navigation

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

About

Gapless audio playback javascript plugin (WIP)

Resources

License

Stars

Watchers

Forks

Sponsor this project

 

Packages

No packages published

Languages

  • TypeScript 55.8%
  • JavaScript 36.0%
  • HTML 7.6%
  • Shell 0.6%