howler
is used to initialise the 'howler.js' framework by adding all of the specified tracks to the
player, and can be run by either including UI buttons or server-side actions.
howler(
tracks,
options = list(),
track_formats = NULL,
auto_continue = FALSE,
auto_loop = FALSE,
seek_ping_rate = 1000L,
elementId = NULL
)
A named vector of file paths to sounds. If multiple file extensions are included, then use a named list instead, with each list item containing each extension of the sound.
A named list of options to add to the player. For a full list of options see https://github.com/goldfire/howler.js?tab=readme-ov-file#options
An optional list of formats of the sounds. By default 'howler' will guess the format to play in. Must be the same length as tracks
If there are multiple files, would you like to auto play the next file after the current
one has finished? Defaults to TRUE
Once all files have been played, would you like to restart playing the playlist?
Defaults to FALSE
Number of milliseconds between each update of `input${id}_seek` while playing. Default is set to 1000. If set to 0, then `input${id}_seek` will not exist.
HTML id tag to be given to the howler player element
A shiny.tag containing all of the required options for a Howl
JavaScript
object to be initialised in a shiny application.
On the server side there will be up to four additional objects available as inputs:
{id}_playing
A logical value as to whether or not the howler
is playing audio
{id}_track
Basename of the file currently loaded
{id}_seek
(If seek_ping_rate > 0
) the current time (in seconds) of the track loaded
{id}_duration
The duration (in seconds) of the track loaded
All buttons associated with the howler
should be given the same id
argument. This is to ensure
that the buttons are linked to the player.
i.e. If howler(id = "howler")
, then howlerPlayButton(id = "howler")
if (FALSE) { # interactive()
library(shiny)
ui <- fluidPage(
title = "howler.js Player",
howler(elementId = "howler", c(sound = "audio/sound.mp3")),
howlerPlayPauseButton("howler")
)
server <- function(input, output) {
}
shinyApp(ui, server)
# Multiple file formats
howler(
elementId = "howler",
list(
track_1 = c("audio/sound.webm", "audio/sound.mp3"),
track_2 = c("audio/sound2.webm", "audio/sound2.mp3"),
)
)
}