Preparing search index...

    Class LyricsTracker

    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.

    Lens Scripting Version 297

    // 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);
    });
    }
    }

    Hierarchy (View Summary)

    Index

    Properties

    currentLine: LyricsLine

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

    Lens Scripting Version 297

    fullLyrics: Lyrics

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

    Lens Scripting Version 297

    isPlaying: boolean

    Returns true if the tracked audio is playing.

    Lens Scripting Version 297

    nextLine: LyricsLine

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

    Lens Scripting Version 297

    onLineEnd: event1<LyricsLine, void>

    Event that triggers when a LyricsLine has ended.

    Lens Scripting Version 297

    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.

    Lens Scripting Version 297

    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.

    Lens Scripting Version 297

    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.

    Lens Scripting Version 297

    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.

    Lens Scripting Version 297

    onPlaybackStarted: event1<ExternalMusicInfo, void>

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

    Lens Scripting Version 297

    onWordEnd: event1<LyricsSync, void>

    Event that triggers when a LyricsSync has ended.

    Lens Scripting Version 297

    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.

    Lens Scripting Version 297

    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.

    Lens Scripting Version 297

    Methods

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

      Parameters

      • type: string

      Returns boolean

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

      Parameters

      Returns boolean