amplitudejs icon indicating copy to clipboard operation
amplitudejs copied to clipboard

Browser requests song url every time you skip to a new location in the song

Open sbrattla opened this issue 3 years ago • 0 comments

Issue description

When you Amplitude.skipTo() to a new location for the currently playing audio, a request is being made for the URL of the audio. This happens every time you skip to a new location in the currently loaded / playing audio.

Environment

  • What's My Browser Support link: https://www.whatsmybrowser.org/b/XECCG
  • Amplitude.js Version: 5.3.0

Steps to reproduce the issue

  1. Load a song with Amplitude.addSong({url: [url]});
  2. Skip to a new location with Amplitude.skipTo(5, 0)

Every time you skip to a new location, a new request is being made by the browser for the song url.

What is expected?

I would expect a request not to be made as long as you skip within the already loaded song.

Additional details / screenshots

I can see that this happens in audioNavigation.js and it's changeSong() function. By setting config.audio.src = song.url every time a skip to a new location is done, this triggers the browser to request the song url again.

By wrapping this section in a check to validate if the song url is the same, the request is avoided :

    /*
      Change the song if the song.url is different from the current audio.src.
    */
    if (_config2.default.audio.src !== song.url) {
      _config2.default.audio.src = song.url;
      _config2.default.active_metadata = song;
      _config2.default.active_album = song.album;
    }

sbrattla avatar Mar 03 '22 10:03 sbrattla