Kind: global class
This object creates a custom Audio Player instance, which is an extension of the native DOM tag. All native functionality is available, such as load(), play(), pause(), and volume
Example
import { AudioPlayer } from 'ad-video'
// instantiate new audio player
View.main.audioPlayer = new AudioPlayer({
source: 'mySoundFile.mp3',
target: View.main,
id: 'My_Unique_ID',
preload: false,
autoPlay: false,
muted: false,
volume: .8,
onReady: function(event) {
console.log('audio ready')
},
onProgress: function(event) {
console.log('audio progress')
},
onComplete: function(event) {
console.log('audio complete')
},
onFail: global.failAd,
})
View.main.audioPlayer.play()
A Boolean that changes if the audio will automatically play.
Kind: static property of AudioPlayer
Example
myPlayer.autoPlay = false;
A Number 0-1 representing the audio timeline percent position.
Kind: static property of AudioPlayer
Changes the source of the audio. Pass a string of the audio file path to set.
Kind: static property of AudioPlayer
Example
myPlayer.source = 'audio/myAudio.mp3';
Loads the current audio source. If preload is true, this is redundant.
Kind: static method of AudioPlayer
Example
myPlayer.load();
Plays the current audio.
Kind: static method of AudioPlayer
Example
myPlayer.play();
Pauses the current audio.
Kind: static method of AudioPlayer
Example
myPlayer.pause();
Skips the audio to a specific time.
Kind: static method of AudioPlayer
Param | Type | Description |
---|---|---|
sec | number |
The time to skip the audio to in seconds. |
Example
myPlayer.seek( 4 );
Stops the audio and resets it to the beginning.
Kind: static method of AudioPlayer
Example
myPlayer.stop();
Mutes the Video Player, does not change the volume.
Kind: static method of AudioPlayer
Example
myPlayer.mute()
Unmutes the Video Player, does not change the volume.
Kind: static method of AudioPlayer
Example
myPlayer.unmute()