-
Notifications
You must be signed in to change notification settings - Fork 146
Source Interface Reference
The AV.Source
interface describes the necessary methods one must provide to implement a valid data source for Aurora. There is no concrete AV.Source
class provided by the framework, but two implementations of the interface are provided: AV.HTTPSource
and AV.FileSource
.
You normally do not use sources directly, but rather you use the fromURL
and fromFile
class methods on the AV.Asset. However, you can implement additional sources and use them with the AV.Asset constructor manually.
Causes the source to start loading data. The source must emit data, progress, and end events following the call to start
. Emitting an error event will cause the pause method to be called and the loading to be aborted.
Causes the source to pause loading data, but not reset state such that calling start starts the source right where it left off.
Resets the source's state to the beginning of the data stream. If the source does not have a specific beginning (in the case of a streaming audio source for example), this method should have no effect.
The data event should be emitted as soon as the source has data available. Data should be emitted in chunks, and should not be loaded all at once and emitted all together if possible. The argument to the 'data' event should be an AV.Buffer object containing the loaded data.
The progress event should be emitted as the data is being loaded, as often as reasonably possible. The argument should be a percentage between 0 and 100 representing the amount of data loaded (loaded / total * 100
). If the total size of the file is unknown, then the event should not be emitted.
The error event should be emitted when there is an error while loading data. It will trigger the pause and cancel loading the asset.
The end event should be triggered when the source has loaded all data available.