Skip to content

Asset Class Reference

devongovett edited this page Nov 12, 2012 · 8 revisions

The AV.Asset class is responsible for managing all aspects of the decoding pipeline from source to decoder. You can use the AV.Asset class to inspect information about an audio file, such as its format, metadata, and duration, as well as actually decode the file to raw linear PCM audio data.

Constructors

Properties

Methods

Events

Constructors

new AV.Asset(source)

Creates an AV.Asset with the specified AV.Source.

Asset.fromURL(url)

Creates an AV.Asset with an AV.HTTPSource pointing to the specified url.

Asset.fromFile(file)

Creates an AV.Asset with a AV.FileSource pointing to the specified File.

Properties

AV.Asset#buffered

The percentage of the audio file that has been buffered by the source.

AV.Asset#duration

The duration of the audio file in milliseconds.

AV.Asset#format

The format object describing the audio format as returned by the demuxer.

AV.Asset#metadata

An object containing any metadata embedded in the audio file.

AV.Asset#active

A boolean indicating whether the decoding pipeline is currently active.

AV.Asset#source

The backing AV.Source object for the asset.

AV.Asset#demuxer

The backing AV.Demuxer object for the asset, or null if demuxing hasn't started yet.

Asset#decoder

The backing AV.Decoder object for the asset, or null if decoding hasn't started yet.

Methods

AV.Asset#start()

Starts the decoding process of the asset.

AV.Asset#stop()

Pauses the decoding process of the asset.

AV.Asset#get(event, callback)

Used for inspecting various parts of an audio file without actually decoding the entire file. event is allowed to be either 'format', 'duration', or 'metadata'. If the requested property has already been decoded at the time get is called, the callback is invoked immediately. Otherwise, the asset waits until the requested event is emitted, at which point the callback is called and decoding is stopped.

Events

'buffer', percent

Emitted while the audio file is being loaded with a percentage between 0 and 100 representing the amount of the file that has been read so far.

'format', object

Emitted when the demuxer has decoded enough information to determine basic format information about the audio file.

'duration', msecs

Emitted when the duration of the audio file has been parsed.

'metadata', object

Emitted when any embedded metadata is decoded.

'decodeStart'

Emitted when decoding of the actual audio data begins.

'data', buffer

Emitted when audio data is decoded. buffer is a Typed Array containing decoded Linear PCM audio.

'error', err

Emitted when the an error is encountered in the decoding process. Whenever an error is encountered, the decoding process is also stopped automatically.

Clone this wiki locally