Skip to content

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

@sbrattla

Description

@sbrattla

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

  • 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;
    }

Metadata

Metadata

Assignees

Labels

Bug: Needs Confirmation 🧐Bugs that are reported, but needs to be confirmed and replicated.

Type

No type

Projects

Status

Being Documented

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions