playSound {howler}R Documentation

Play Sound

Description

Using howler.js, play a sound within a shiny application.

Usage

playSound(track, options = NULL, session = getDefaultReactiveDomain())

Arguments

track

Either a URL, file path or Base 64 character string of the sound to play

options

A named list of options to add to the sound. For a full list of options see https://github.com/goldfire/howler.js?tab=readme-ov-file#options

session

Shiny session

Details

The 'src' and 'autoplay' options are pre-determined by 'playSound' and are not required in 'options'. If they are included, a warning will be printed and they will be ignored from the list.

Examples


library(shiny)

audio_files_dir <- system.file("examples/_audio", package = "howler")
addResourcePath("sample_audio", audio_files_dir)

ui <- fluidPage(
  actionButton("play", "Play Sound")
)

server <- function(input, output) {
  observeEvent(input$play, {
    playSound("sample_audio/running_out.mp3")
  })
}

shinyApp(ui, server)


[Package howler version 0.3.0 Index]