If you implement an app that plays multiple sounds, which are background music and sound effects, you need to read the following guidelines and sample code carefully.
In this article, we explain both the audio element and the Web Audio API for playing multiple sounds. Due to restrictions, however, we strongly recommend you to use the audio element for playing background music.
You should use only one audio element in your app. As the audio tag uses the hardware decoder on webOS TV, sometimes media resource conflict occurs while apps are switching. To prevent the media resource conflict on webOS TV, you should use only one audio element in your app. If you declare one or more audio elements in your app, sounds are not played at the same time.
The duration of audio content must be at least 1 second.
On app suspend, you should pause the sound and resume it when the app goes foreground. Refer to the sample code.
Multi-sound works with multiple audio elements on the webOS TV Emulator that are working differently from the real device.
Use Case for Audio Element
Playing background music in your app.
Supported MIME Types
Following MIME types are supported in the audio element:
The following example shows that a file of the mp3 format is played with the audio element.
<audio controls autoplay> <source type="audio/mp3" src="http://media.w3.org/2010/05/sound/sound_300.mp3"/> </audio>
For your reference, see Web Audio API specifications and references below.
createMediaElementSource() method is not supported on the webOS TV.
As only one audio element can be used in an app, you should use Web Audio API for playing sound effects.
When playing sound with Web Audio API, it has the about 500-millisecond latency issue in webOS TV, so you should be aware of this before using Web Audio API in your app.
Use Case for Web Audio API
Playing sound effects in your app.
Supported Media Formats
Refer to Supported Media and DRM Format.
You cannot use SoundFont on webOS TV, which is a file format and associated technology for the computer music composition, which mostly contains multiple sounds inside.