Skip to content

SPIKE: "sticky" audio player - #562

Open
floehopper wants to merge 1 commit into
mainfrom
permanent-player
Open

floehopper wants to merge 1 commit into
mainfrom
permanent-player

Conversation

@floehopper

Copy link
Copy Markdown
Member

This adds an extra "play" button below the "Buy" button on the album page. Clicking the new "play" button reveals an unstyled "sticky" player at the bottom of the page with "previous", "play", "pause" & "next" controls and displaying the title of each track and the percentage played. This "sticky" player persists when the user navigates away from the album page until the "close" button is clicked.

The "sticky" player is implemented in app/views/layouts/_permanent_player.html.erb and rendered as part of the application layout with the JS behaviour implemented in app/javascript/controllers/permanent_player_controller.js.

The new play button is implemented in app/views/albums/_play_button.html.erb and rendered as part of the album show page with the JS behaviour implemented in app/javascript/controllers/play_button_controller.js. The click function in this Stimulus controller calls the load function in app/javascript/controllers/permanent_player_controller.js using a Stimulus outlet.

TODO:

  • Decide whether to keep any of the existing player behaviour on the album page.
  • Remove duplication of track data in album show page (JSON & HTML)
  • Style the "sticky" player.
  • Consider displaying the track duration.
  • Decide whether/how to handle tracks with no file/preview.
  • Add tests.

Note that I wrote all the above many months after I did the bulk of the implementation, so I may have forgotten stuff!

This adds an extra "play" button below the "Buy" button on the album page.
Clicking the new "play" button reveals an unstyled "sticky" player at the
bottom of the page with "previous", "play", "pause" & "next" controls and
displaying the title of each track and the percentage played. This "sticky"
player persists when the user navigates away from the album page until the
"close" button is clicked.

The "sticky" player is implemented in
`app/views/layouts/_permanent_player.html.erb` and rendered as part of the
application layout with the JS behaviour implemented in
`app/javascript/controllers/permanent_player_controller.js`.

The new play button is implemented in `app/views/albums/_play_button.html.erb`
and rendered as part of the album show page with the JS behaviour implemented
in `app/javascript/controllers/play_button_controller.js`. The `click` function
in this Stimulus controller calls the `load` function in
`app/javascript/controllers/permanent_player_controller.js` using a Stimulus
outlet [1].

TODO:
* Decide whether to keep any of the existing player behaviour on the album page.
* Remove duplication of track data in album show page (JSON & HTML)
* Style the "sticky" player.
* Consider displaying the track duration.
* Decide whether/how to handle tracks with no file/preview.
* Add tests.

[1]: https://stimulus.hotwired.dev/reference/outlets

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant