HOW TO
In ArcGIS Experience Builder, audio files are often included in web apps as attachments or play buttons that require manual interaction after a feature is selected. This user experience can be enhanced by automating the audio playback upon feature selection.
This article provides the workflow to configure pop-ups based on string field values using Arcade expressions in ArcGIS Online Map Viewer to enable automatic audio playback in ArcGIS Experience Builder.
// Declare a variable to store the HTML audio output
var audioOutput
// Check if the feature field equals "Example"
if ($feature.name == "Example")
// If the condition is true, assign an HTML audio element to 'audioOutput'
// The audio element will autoplay and use the specified MP3 file as its source
{ audioOutput = `<audio autoplay>
<source src="AttachmentURL.mp3" type="audio/mp3">
</audio>`
}
//Use audioOutput = <audio controls> for a play button instead of autoplay
//Repeat the above conditional block for each point or category with an audio file
// Return an object that defines the output type and content
return {
type : 'text', // Specifies that the output is text
text : audioOutput // The text property supports HTML tags, so the audio will play
}
// Declare a variable to store the HTML audio output
var audioOutput
// Check if the feature field equals "Example"
if ($feature.name == "Example")
// If the condition is true, assign an HTML audio element to 'audioOutput'
// The audio element will autoplay and use the specified MP3 file as its source
{
audioOutput = `<audio autoplay>
<source src="AttachmentURL.mp3" type="audio/mp3">
</audio>`
}
// Check if the feature field equals "Example 2"
if ($feature.name == "Example 2")
{
audioOutput = `<audio autoplay>
<source src=" AttachmentURL.mp3" type="audio/mp3">
</audio>`
}
// Use audioOutput = <audio controls> for a play button instead of autoplay
// Repeat the above conditional block for each point or category with an audio file
// Return an object that defines the output type and content
return {
type : 'text', // Specifies that the output is text
text : audioOutput // The text property supports HTML tags, so the audio will play
}
Article ID: 000039400
Get help from ArcGIS experts
Start chatting now