Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't initialize Amplitude with playlists only #440

Open
Sun0fABeach opened this issue Jul 3, 2020 · 3 comments
Open

Can't initialize Amplitude with playlists only #440

Sun0fABeach opened this issue Jul 3, 2020 · 3 comments
Assignees
Labels
Bug: Confirmed 🐛 Bugs that have been replicated and need to be addressed.

Comments

@Sun0fABeach
Copy link

Issue description

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

Environment

  • Amplitude.js Version: 5.0.3

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'
    }
  }
})
  1. 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.

@Sun0fABeach Sun0fABeach added the Bug: Needs Confirmation 🧐 Bugs that are reported, but needs to be confirmed and replicated. label Jul 3, 2020
@jaydrogers
Copy link
Member

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
Copy link
Author

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

  • when I try to play the song by clicking on said element, I get the following console error:
amplitude.js Uncaught TypeError: Cannot set property 'active_index' of undefined
    at Object.setActivePlaylist
    at handleSongInPlaylistPlayPause
    at HTMLLIElement.handle
  • when I initialize Amplitude with debug: true, I get the following console message:
Please provide a songs object for AmplitudeJS to run!

Looks like someone explicitly decided to check for the songs property and to print that message + abort initialization when it's not there. Since it's possible to define all the songs in the playlist config, that check should be made smarter.

@danpastori
Copy link
Contributor

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.

@danpastori danpastori reopened this Feb 16, 2021
@danpastori danpastori added Bug: Confirmed 🐛 Bugs that have been replicated and need to be addressed. and removed Bug: Needs Confirmation 🧐 Bugs that are reported, but needs to be confirmed and replicated. labels Feb 16, 2021
@danpastori danpastori moved this to Being Documented in AmplitudeJS 6.0 May 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug: Confirmed 🐛 Bugs that have been replicated and need to be addressed.
Projects
Status: Being Documented
Development

No branches or pull requests

3 participants