November 2019
Beginner
436 pages
8h 52m
English
In real life, you aren't going to have two separate buttons for playback. Typically, users prefer having a single button that both starts and pauses the song.
Luckily, AmplitudeJS provides support for this scenario as well. Here, we can use amplitude-play-pause to make an HTML element toggle the playback. The usage format is pretty much the same as it was for the Play and Pause functionality:
<span class="amplitude-play-pause"></span>
Comment out or remove the Play and Pause buttons and use a new unified button, as shown in the following code:
<!DOCTYPE html><html> <head> <meta charset="UTF-8" /> <title>Music Player</title> </head> <body> <h1>Music Player</h1> <div> <button class="amplitude-play-pause">Play ...
Read now
Unlock full access