Skip to content

Latest commit

 

History

History
152 lines (123 loc) · 3.68 KB

AudioPlayer.md

File metadata and controls

152 lines (123 loc) · 3.68 KB

AudioPlayer

Kind: global class

new AudioPlayer()

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()

AudioPlayer.autoPlay : boolean

A Boolean that changes if the audio will automatically play.

Kind: static property of AudioPlayer
Example

myPlayer.autoPlay = false;

AudioPlayer.percent : number

A Number 0-1 representing the audio timeline percent position.

Kind: static property of AudioPlayer

AudioPlayer.source : string

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';			

AudioPlayer.load()

Loads the current audio source. If preload is true, this is redundant.

Kind: static method of AudioPlayer
Example

myPlayer.load();

AudioPlayer.play()

Plays the current audio.

Kind: static method of AudioPlayer
Example

myPlayer.play();

AudioPlayer.pause()

Pauses the current audio.

Kind: static method of AudioPlayer
Example

myPlayer.pause();

AudioPlayer.seek(sec)

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 );

AudioPlayer.stop()

Stops the audio and resets it to the beginning.

Kind: static method of AudioPlayer
Example

myPlayer.stop();

AudioPlayer.mute()

Mutes the Video Player, does not change the volume.

Kind: static method of AudioPlayer
Example

myPlayer.mute()

AudioPlayer.unmute()

Unmutes the Video Player, does not change the volume.

Kind: static method of AudioPlayer
Example

myPlayer.unmute()