HTML::O...deoTrack(3)

πŸ“¦ version 0.6.0, in alpine 3.24

NAME πŸ’–

HTML::Object::DOM::VideoTrack β€” the HTML Object DOM VideoTrack Class, aka the little object that represents one (1) single video track from a <video> element. Slay.


SYNOPSIS ✨

use HTML::Object::DOM::VideoTrack;
my $track = HTML::Object::DOM::VideoTrack->new ||
    die( HTML::Object::DOM::VideoTrack->error, "\n" );

Like, that's it. That's the whole vibe check.


VERSION πŸŽ€

v0.2.0

DESCRIPTION πŸ¦‹

Okay so the VideoTrack interface represents a single video track from a <video> element. One track. Singular. Main character energy, no sharing the spotlight.

To actually get a VideoTrack for a given media element, you use the element's videoTracks property β€” that hands you back a VideoTrackList object, and from there you can grab the individual tracks living inside the media. Like this:

my $el = $doc->querySelector('video');
my $tracks = $el->videoTracks;
my $firstTrack = $tracks->[0];

And now the fun part β€” scanning through all of the media's video tracks and activating the first one that's in the user's preferred language (which comes from a variable called userLanguage, iykyk):

for( my $i = 0; $i < $tracks->length; $i++ )
{
    if( $tracks->[$i]->language eq $userLanguage )
    {
        $tracks->[$i]->selected = 1; # true
        last;
    }
});

Obsessed with her honestly. πŸ’…


INHERITANCE πŸ‘‘

The family tree, bestie:

+-----------------------+     +---------------------------+     +-------------------------------+
| HTML::Object::Element | --> | HTML::Object::EventTarget | --> | HTML::Object::DOM::VideoTrack |
+-----------------------+     +---------------------------+     +-------------------------------+

Three generations of iconic behavior.


PROPERTIES 🌸

She inherits properties from her parent HTML::Object::EventTarget (go off, ancestry).

id πŸ’–

Sets or gets a string that uniquely identifies the track within the media. This ID is how you locate a specific track inside a video track list β€” you do it by calling "VideoTrackList".getTrackById(). Oh and also? The ID can be used as the fragment part of the URL if the media supports seeking by media fragment per the Media Fragments URI specification. Versatile queen.

Returns the ID as a scalar object.

See also Mozilla documentation at https://developer.mozilla.org/en-US/docs/Web/API/VideoTrack/id

kind πŸŽ€

A string specifying the category the track falls into. For example, the main video track would have a kind of "main". Categorization, but make it fashion.

See also Mozilla documentation at https://developer.mozilla.org/en-US/docs/Web/API/VideoTrack/kind

label ✨

A string giving you a human-readable label for the track. For example, a track whose kind is "sign" might have a label of "A sign-language interpretation". And if no label is provided? This string is just empty. Respectfully, fair.

Example:

use Module::Generic::Array;
sub getTrackList
{
    my $el = shift( @_ );
    my $trackList = Module::Generic::Array->new;
    my $wantedKinds = [qw( main alternative commentary )];

    $el->videoTracks->forEach(sub
    {
        my $track = shift( @_ );
        if( $wantedKinds->includes( $track->kind ) )
        {
            $trackList->push({
                id    => $track->id,
                kind  => $track->kind,
                label => $track->label
            });
        }
    });
    return( $trackList );
}

See also Mozilla documentation at https://developer.mozilla.org/en-US/docs/Web/API/VideoTrack/label

language πŸ¦‹

A string specifying the video track's primary language β€” or an empty string if it's unknown, no judgment. The language is specified as a BCP 47 (RFC 5646 at https://datatracker.ietf.org/doc/html/rfc5646) language code, such as "en-US" or "ja-JP".

Returns the language as a scalar object.

See also Mozilla documentation at https://developer.mozilla.org/en-US/docs/Web/API/VideoTrack/language

selected πŸ”₯

A boolean value that controls whether or not the video track is active. Heads up though: only a single video track can be active at any given time, so if you set this property to true for one track while another track is active, that other track goes inactive. Periodt. One at a time, we don't do chaos here.

See also Mozilla documentation at https://developer.mozilla.org/en-US/docs/Web/API/VideoTrack/selected

sourceBuffer πŸ’€

This always returns "undef" under perl. Yep. Always.

Normally, under JavaScript, this is the "SourceBuffer" that created the track. It returns "undef" if the track was not created by a "SourceBuffer", or if the "SourceBuffer" has been removed from the "MediaSource.sourceBuffers" attribute of its parent media source. Not me explaining the whole situation. πŸ™ˆ

See also Mozilla documentation at https://developer.mozilla.org/en-US/docs/Web/API/VideoTrack/sourceBuffer


METHODS ⭐

Inherits methods from her parent HTML::Object::EventTarget. That's the whole section, bestie β€” she's lowkey mysterious like that.


AUTHOR 🌈

Jacques Deguest <jack@deguest.jp>


SEE ALSO 🧚

Mozilla documentation at https://developer.mozilla.org/en-US/docs/Web/API/VideoTrack


Copyright(c) 2021 DEGUEST Pte. Ltd.

All rights reserved

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.


and that's the whole manpage bestie πŸ’œ go forth and track those videos fr fr

perl v5.42.2 Β· 2026-02-15 Β· HTML::O...deoTrack(3) β€” mwah, catch you on the next one πŸ«ΆπŸ“

πŸ“¦ where this page comes from