serversideup / amplitudejs

AmplitudeJS: Open Source HTML5 Web Audio Library. Design your web audio player, the way you want. No dependencies required.
https://521dimensions.com/open-source/amplitudejs
MIT License
4.19k stars 424 forks source link

Can't initialize Amplitude with playlists only #440

Open Sun0fABeach opened 4 years ago

Sun0fABeach commented 4 years ago

Issue description

Amplitude doesn't properly initialize if I provide a playlist config containing all the songs, and leave out the songs array.

Environment

Steps to reproduce the issue

  1. Initialize Amplitude like so. Note that the only song here is defined inside a playlist and there is no top-level songs array:
    Amplitude.init({
    playlists: {
    emancipator: {
      songs: [{
        "name": "Anthem",
        "artist": "Emancipator",
        "album": "Soon It Will Be Cold Enough",
        "url": "../songs/Anthem-Emancipator.mp3",
        "cover_art_url": "../album-art/soon-it-will-be-cold-enough.jpg"
      }],
      title: 'Emancipator\'s Greatest Hits'
    }
    }
    })
  2. Try to play the song by clicking on an element with class="amplitude-play-pause" data-amplitude-song-index="0" data-amplitude-playlist="emancipator"

What is expected?

The song is played.

Additional details / screenshots

I can make it work by providing a dummy element for songs like so:

Amplitude.init({
  songs: [{ url: "" }],
  playlists: {
    emancipator: {
      songs: [{
        "name": "Anthem",
        "artist": "Emancipator",
        "album": "Soon It Will Be Cold Enough",
        "url": "../songs/Anthem-Emancipator.mp3",
        "cover_art_url": "../album-art/soon-it-will-be-cold-enough.jpg"
      }],
      title: 'Emancipator\'s Greatest Hits'
    }
  }
})

Now the song can be played.

jaydrogers commented 4 years ago

Hey @Sun0fABeach, thanks for the detailed bug report.

Dan made a few bug fixes in v5.1.0.

Can you let us know if you are still having the issue in the latest version?

Sun0fABeach commented 4 years ago

Hi. I upgraded to v5.1.0 and the issue remains. Further observations that might help:

danpastori commented 3 years ago

After the merger and release of v5.3.0, we re-opened this and need to revisit how to initialize AmplitudeJS without a playlist. This was fixed in v5.2., but due to a host of other issues, we had to rebase and move forward. I'll explore options to make sure this works without issue.