Home Reference Source Repository
import DHAudio from 'dh3dlib/js/base/DHAudio.js'
public class | source

DHAudio

DHAudio class

Constructor Summary

Public Constructor
public

constructor

Method Summary

Public Methods
public

check if it can play MP3 file

public

check if it can play OGG file

public

check if browser can play the given type of sound file

public

pause sound

public

play sound

public

play sound

public

playDistanceDirection(distance: float, direction: float): float

play sound from given distance and direction

public

setListener(listener: Camera): boolean

set listener object

public

setSound(leftSnd: HTMLAudioElement, rightSnd: HTMLAudioElement): boolean

set sound file to play

public

set sound source

Public Constructors

public constructor source

constructor

Public Methods

public canPlayMP3(): boolean source

check if it can play MP3 file

Return:

boolean

true: can play MP3 file, false: can't play MP3 file

public canPlayOGG(): boolean source

check if it can play OGG file

Return:

boolean

true: can play OGG file, false: can't play OGG file

public canPlayType(type: string): boolean source

check if browser can play the given type of sound file

Params:

NameTypeAttributeDescription
type string

String of type

Return:

boolean

true: can play, false: can't play

public pause(): boolean source

pause sound

Return:

boolean

true: success, false: failure

public play(): boolean source

play sound

Return:

boolean

true: success, false: failure

public playAt(): boolean source

play sound

Return:

boolean

true: success, false: failure

public playDistanceDirection(distance: float, direction: float): float source

play sound from given distance and direction

Params:

NameTypeAttributeDescription
distance float

distance from sound source

direction float

0: left, 1: right

Return:

float

true: success, false: failure

public setListener(listener: Camera): boolean source

set listener object

Params:

NameTypeAttributeDescription
listener Camera

listener object

Return:

boolean

true: success, false: failure

public setSound(leftSnd: HTMLAudioElement, rightSnd: HTMLAudioElement): boolean source

set sound file to play

Params:

NameTypeAttributeDescription
leftSnd HTMLAudioElement

Sound file for left side

rightSnd HTMLAudioElement

Sound file for right side

Return:

boolean

true: success, false: failure (likely can't play given files)

public setSoundSource(sndSrc: DH3DObject): boolean source

set sound source

Params:

NameTypeAttributeDescription
sndSrc DH3DObject

sound source

Return:

boolean

true: success, false: failure