Skip to main content

LyricsTracker

Class

Provides information about lyrics data for a currently playing track.

  • Available on all platforms
Platform details: Snapchat, SPECS, Camera Kit Web, Camera Kit Mobile fully supported.

Platform details

  • Snapchat — Fully supported.

  • SPECS — Fully supported.

  • Camera Kit Web — Fully supported.

  • Camera Kit Mobile — Fully supported.

Since Lens Scripting v297

Provides information about lyrics data for a currently playing track. Can be accessed through getLyricsTracker() on ExternalMusicModule.

Note that lyrics data may not be available immediately when this class is accessed. Subscribe to onLyricsAvailable to be notified when lyrics data becomes available.

Also note that some music tracks may not support lyrics. In this case, onLyricsAvailable will not be triggered.

Index

Example

// Import ExternalMusicModule through require() or @input
const externalMusicModule = require("LensStudio:ExternalMusicModule") as ExternalMusicModule;

@component
export class LyricsExample extends BaseScriptComponent {
// Make sure an AudioTrack asset is included in the scene. It determines the track that plays.
// If you see errors, make sure that "Bundled" is unchecked (disabled) on the AudioTrack.
@input audioAsset: AudioTrackAsset;

onAwake() {
const lyricsTracker = externalMusicModule.getLyricsTracker();

lyricsTracker.onLyricsAvailable.add(() => {
print("Lyrics are available!");
print("Is rich sync data available: " + (lyricsTracker.fullLyrics.type == LyricsType.RichSync));
});

lyricsTracker.onLyricsCleared.add(() => {
print("Lyrics have been cleared.")
});

// Every time a line starts, print the full text of the line
lyricsTracker.onLineStart.add(line => {
print("Line starting: " + line.fullLineText);
});

// Every time a word starts, print the word text
lyricsTracker.onWordStart.add(word => {
print("Word starting: " + word.text);
});
}
}

Extends

Properties

currentLine

readonly currentLine: LyricsLine

The current LyricsLine for the tracked music. Returns null if no line is currently playing, or lyrics are not available.

Since

Lens Scripting Version 297


fullLyrics

readonly fullLyrics: Lyrics

The full Lyrics for the tracked music. Useful for pre-processing the lyrics of a track ahead of time.

Since

Lens Scripting Version 297


isPlaying

readonly isPlaying: boolean

Returns true if the tracked audio is playing.

Since

Lens Scripting Version 297


nextLine

readonly nextLine: LyricsLine

The next LyricsLine for the tracked music. Returns null if no next line is present, or lyrics data is not available.

Since

Lens Scripting Version 297


onLineEnd

readonly onLineEnd: event1<LyricsLine, void>

Event that triggers when a LyricsLine has ended.

Since

Lens Scripting Version 297


onLineStart

readonly onLineStart: event1<LyricsLine, void>

Event that triggers when a LyricsLine has started. Note that if playback begins partway through a line, this event will immediately fire.

Since

Lens Scripting Version 297


onLyricsAvailable

readonly onLyricsAvailable: event0<void>

Event that triggers when lyrics data becomes available for the tracked music. Note that when lyrics are not available for the selected music track, this event will never trigger.

Since

Lens Scripting Version 297


onLyricsCleared

readonly onLyricsCleared: event0<void>

Event that fires when lyrics data is cleared. This usually indicates that the tracked music has either been removed or changed. It's good practice to clear any lyrics visuals when this event fires.

Since

Lens Scripting Version 297


onPlaybackReset

readonly onPlaybackReset: event0<void>

Event that triggers when playback has been reset on the tracked music. It's good practice to clear any lyrics visuals when this event fires.

Since

Lens Scripting Version 297


onPlaybackStarted

readonly onPlaybackStarted: event1<ExternalMusicInfo, void>

Event that triggers when playback has started on the tracked music.

Since

Lens Scripting Version 297


onWordEnd

readonly onWordEnd: event1<LyricsSync, void>

Event that triggers when a LyricsSync has ended.

Since

Lens Scripting Version 297


onWordStart

readonly onWordStart: event1<LyricsSync, void>

Event that triggers when a LyricsSync has started. Note that if playback begins partway through a LyricsSync, this event will immediately fire.

Since

Lens Scripting Version 297


playbackPosition

readonly playbackPosition: number

Current playback position (in seconds) of the tracked music.

This can be used to compare playback position to the offset and offsetEnd properties on LyricsLine objects. It can also be used with offsets on LyricsSync objects, after adjusting their offsets by the offset of the LyricsLine they belong to.

Since

Lens Scripting Version 297

Methods

getTypeName()

static getTypeName(): TypeName<LyricsTracker>

Returns the fully-qualified JavaScript type name for this class (for example, "Component.Camera"). This is a static accessor (no instance required) and returns the same value as the instance getTypeName().

Returns

TypeName<LyricsTracker>

Since

Lens Scripting Version 297

Overrides

ScriptObject.getTypeName


getTypeName()

getTypeName(): string

Returns the name of this object's type.

Returns

string

Inherited from

ScriptObject.getTypeName


isOfType()

isOfType(type): boolean

Returns true if the object matches or derives from the passed in type.

Parameters

ParameterType
typestring

Returns

boolean

Inherited from

ScriptObject.isOfType


isSame()

isSame(other): boolean

Returns true if this object is the same as other. Useful for checking if two references point to the same thing.

Parameters

ParameterType
otherScriptObject

Returns

boolean

Inherited from

ScriptObject.isSame