When you implement an app that plays multi-sound 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 Web Audio API for playing multi-sound. Due to restriction, however, we strongly recommend using the audio element for playing background music.
You should use only one audio element in your webOS TV app. As the audio tag uses hardware decoder and app switching is supported, sometimes media resource conflict occurs. To prevent the media resource conflict in 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 in the webOS TV Emulator which 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 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 in the webOS TV, which is a file format and associated technology for the computer music composition which mostly contains multiple sounds inside.