Home Manual Reference Source
import WebAudioPlayer from 'itslanguage/audio/web-audio-player.js'
private class | source

WebAudioPlayer

Constructor Summary

Public Constructor
public

constructor(options: Object)

ITSLanguage WebAudioPlayer non-graphical component.

Member Summary

Public Members
public

sound: *

Private Members
private
private

Method Summary

Public Methods
public

Returns ready state of the player.

public
public

Returns the percentage of which the buffer is filled.

public

Returns the current playing time as offset in seconds from the start.

public

Returns the total duration in seconds.

public
public

Returns state of the player.

public

load(url: string, preload: boolean, loadedCb: Function)

Preload audio from an URL.

public

pause()

Pause playback of audio.

public

play(position: number)

Start or continue playback of audio.

public

Start preloading audio.

public

reset()

Unload previously loaded audio.

public

scrub(percentage: number)

Start playing audio at the given offset.

public

setAudioVolume(volume: *)

public

setPlaybackRate(rate: *)

public

stop()

Stop playback of audio.

Private Methods
private

Public Constructors

public constructor(options: Object) source

ITSLanguage WebAudioPlayer non-graphical component.

This player uses the HTML5 Audio component for playback.

Params:

NameTypeAttributeDescription
options Object
  • nullable: true

Override any of the default settings.

Public Members

public sound: * source

Private Members

private _pauseIsStop: boolean source

private _settings: * source

Public Methods

public canPlay(): boolean source

Returns ready state of the player.

Return:

boolean

True when player is ready to start loading data or play. False when no audio is loaded or preparing.

public getAudioVolume(): * source

Return:

*

public getBufferFill(): number source

Returns the percentage of which the buffer is filled.

Return:

number

Percentage of buffer fill.

public getCurrentTime(): number source

Returns the current playing time as offset in seconds from the start.

Return:

number

Time in seconds as offset from the start.

public getDuration(): number source

Returns the total duration in seconds.

Return:

number

Time in seconds of fragment duration. 0 if no audio is loaded.

public getPlaybackRate(): * source

Return:

*

public isPlaying(): boolean source

Returns state of the player.

Return:

boolean

True when player is currently playing. False when paused or stopped.

public load(url: string, preload: boolean, loadedCb: Function) source

Preload audio from an URL.

Params:

NameTypeAttributeDescription
url string

The URL that contains the audio.

preload boolean
  • optional
  • default: true

Try preloading metadata and possible some audio (default). Set to false to not download anything until playing.

loadedCb Function
  • nullable: true

The callback that is invoked when the duration of the audio file is first known.

public pause() source

Pause playback of audio.

public play(position: number) source

Start or continue playback of audio.

Params:

NameTypeAttributeDescription
position number
  • nullable: true

When position is given, start playing from this position (seconds).

public preload() source

Start preloading audio.

public reset() source

Unload previously loaded audio.

public scrub(percentage: number) source

Start playing audio at the given offset.

Params:

NameTypeAttributeDescription
percentage number

Start at this percentage (0..100) of the audio stream.

public setAudioVolume(volume: *) source

Params:

NameTypeAttributeDescription
volume *

public setPlaybackRate(rate: *) source

Params:

NameTypeAttributeDescription
rate *

public stop() source

Stop playback of audio.

Private Methods

private _initPlayer() source