Home Manual Reference Source
import Player from 'itslanguage/WebAudio/Player.js'
public class | source

Player

Extends:

AudioContext → Player

Player Simple Audio Player based on Web Audio API technology

Member Summary

Private Members
private

Private object to hold AudioBuffer node.

private

Private object to hold AudioBufferSourceNode node.

Method Summary

Public Methods
public

Returns if the audioBuffer has been created and loaded, or not.

public

Return if audioSource has been created, or not.

public
public
public

async load(url: string, withItslToken: boolean)

Get an audio stream from an URL.

public

pause()

public

play()

Start audio playback of that what is in the buffer.

public

stop()

Stop playback of audio.

Inherited Summary

From class AudioContext
public

Private object to hold AudioContext node.

public

This will be the error function.

public

This will be the log function.

private

Keep a list of all registered event listeners.

public

addEventListener(args: ...*)

Wraps the addEventListener which is available on the AudioContext node.

public

Get the audio context or create one.

public

fireEvent(eventName: string, data: Object)

Use this method to conveniently fire an event.

public
public

removeEventListener(args: ...*)

Wraps the removeEventListener which is available on the AudioContext node.

public

Resume a suspended AudioContext.

public

Suspend the AudioContext to preserve power and such.

Private Members

private audioBuffer: * source

Private object to hold AudioBuffer node.

private audioSource: * source

Private object to hold AudioBufferSourceNode node.

Public Methods

public audioBufferExists(): boolean source

Returns if the audioBuffer has been created and loaded, or not.

Return:

boolean

The audioBuffer created.

public audioSourceExists(): boolean source

Return if audioSource has been created, or not.

Return:

boolean

The audioSource created.

public createBufferSource() source

public disconnectBufferSource() source

public async load(url: string, withItslToken: boolean) source

Get an audio stream from an URL.

If the withItslToken is provided (and set to true) use the authorizedRequest method to load the audio. This in effect will set the ITSLanguage bearer token (if available) to the request.

For both request methods goes: there's no check whether you're trying to load from ITSLanguage backend system or not.

Params:

NameTypeAttributeDescription
url string

Url to load.

withItslToken boolean

Make use of authorizedRequest or just request if set to false.

public pause() source

public play() source

Start audio playback of that what is in the buffer.

public stop() source

Stop playback of audio. Check for buffer and source to exist, if not, exit.