LyricsTracker
ClassProvides information about lyrics data for a currently playing track.
- Available on all platforms
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
Properties
Methods
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
readonlycurrentLine: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
readonlyfullLyrics: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
readonlyisPlaying:boolean
Returns true if the tracked audio is playing.
Since
Lens Scripting Version 297
nextLine
readonlynextLine: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
readonlyonLineEnd:event1<LyricsLine,void>
Event that triggers when a LyricsLine has ended.
Since
Lens Scripting Version 297
onLineStart
readonlyonLineStart: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
readonlyonLyricsAvailable: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
readonlyonLyricsCleared: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
readonlyonPlaybackReset: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
readonlyonPlaybackStarted:event1<ExternalMusicInfo,void>
Event that triggers when playback has started on the tracked music.
Since
Lens Scripting Version 297
onWordEnd
readonlyonWordEnd:event1<LyricsSync,void>
Event that triggers when a LyricsSync has ended.
Since
Lens Scripting Version 297
onWordStart
readonlyonWordStart: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
readonlyplaybackPosition: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()
staticgetTypeName():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
getTypeName()
getTypeName():
string
Returns the name of this object's type.
Returns
string
Inherited from
isOfType()
isOfType(
type):boolean
Returns true if the object matches or derives from the passed in type.
Parameters
| Parameter | Type |
|---|---|
type | string |
Returns
boolean
Inherited from
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
| Parameter | Type |
|---|---|
other | ScriptObject |
Returns
boolean