howler {howler}R Documentation

Create a Howler Audio Player

Description

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.

Usage

howler(
  tracks,
  options = list(),
  track_formats = NULL,
  auto_continue = FALSE,
  auto_loop = FALSE,
  seek_ping_rate = 1000L,
  elementId = NULL
)

Arguments

tracks

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.

options

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

track_formats

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

auto_continue

If there are multiple files, would you like to auto play the next file after the current one has finished? Defaults to TRUE

auto_loop

Once all files have been played, would you like to restart playing the playlist? Defaults to FALSE

seek_ping_rate

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.

elementId

HTML id tag to be given to the howler player element

Details

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")

Value

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

See Also

howlerButton, howlerServer

Examples


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"),
  )
)


[Package howler version 0.3.0 Index]