Skip to main content

LensStudio:AssetLibrary.MusicListResponse

Class

Response returned from a music list query, containing either a success result or a service error.

Index

Example

// MusicListResponse is returned by provider.musicService.fetchAsync().
// It has a protected constructor — inspect ok/data/error/cancelled after the call.
const provider = this.pluginSystem.findInterface(
IAssetLibraryProvider.interfaceId
) as import('LensStudio:AssetLibrary').IAssetLibraryProvider;

const envSetting = new EnvironmentSetting();
envSetting.environment = Environment.Production;
envSetting.space = Space.Public;

const filter = new AssetFilter();
filter.searchText = 'chill';

const response = await provider.musicService.fetchAsync(
new AssetListRequest(envSetting, filter)
);

if (response.ok && response.data) {
console.log('Got', response.data.musicAssets.length, 'music tracks');
} else if (response.cancelled) {
console.log('Music fetch was cancelled');
} else if (response.error) {
console.log('Music fetch failed:', response.error.description);
}

Properties

cancelled

readonly cancelled: boolean

Indicates whether the request was cancelled before completion.


data?

readonly optional data?: MusicListSuccess

Holds the successful result of the music list request, if available.


error?

readonly optional error?: ServiceError

Contains the service error if the request failed.


ok

readonly ok: boolean

Indicates whether the request completed successfully without errors.