Audio element

As of June 2019, some browsers implement a new policy preventing multimedia content from automatically playing before the user has interacted with the page. As a consequence, do not assume playback will automatically start if this is the first thing that should happen when your participants land on the page of the experiment. Most often though, you will have a screen asking your participants to click a button or press a key before you try to play any audio, which qualifies as an interaction enabling automatic playback later on.

Audio elements let you add audio streams to the page:

Creation:

newAudio("myAudio", "http://myserver/audio.mp3")

Creates an <audio> tag in the cache.

By default, PennController is set to preload all resources, which means the trial will not start until the audio stream is stored in the browser’s cache.

You can omit the host URL if:
– you have already added it to the list of host URLs with the command PennController.AddHost.
– or, the audio file is contained in a Zip file (see the Using Zip files page)

newAudio("myAudio", "audio.mp3")

You can take a look at the w3schools HTML5 Audio page to learn more about audio support (as of 2020, MP3 files appear to be supported across the board in IE, Firefox, Chrome, Safari and Opera).

Commands

[yadawiki-list category=”Audio element,NonTest command”]]

Tests

[yadawiki-list category=”Audio element,Test command”]