HTML::O...t::Track(3)

πŸ“¦ version 0.6.0, in alpine 3.24

✨ NAME ✨

okay bestie, welcome to HTML::O...t::Track(3) β€” a User Contributed Perl Documentation page β€” aka HTML::Object::DOM::Element::Track, the HTML Object DOM Track Class. She's a whole vibe πŸ’…

✨ SYNOPSIS ✨

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

my $video = $doc->getElementsByTagName('video')->[0];
# or
my $video = $doc->createElement('video');
$video->controls = 1; # true
# Source 1
my $source1 = $doc->createElement('source');
$source1->src = 'https://example.org/some/where/videos/video.webm';
# Source 2
my $source2 = $doc->createElement('source');
$source2->src = 'https://example.org/some/where/videos/video.mp4';
# Track 1
my $track1 = $doc->createElement('track');
$track1->kind = 'subtitles';
$track1->src = 'subtitles-en.vtt';
$track1->label = 'English captions';
$track1->srclang = 'en';
$track1->type = 'text/vtt';
$track1->default = 1; # true
# Track 2
my $track2 = $doc->createElement('track');
$track2->kind = 'subtitles';
$track2->src = 'subtitles-fr.vtt';
$track2->label = 'Sous-titres FranΓ§ais';
$track2->srclang = 'fr';
$track2->type = 'text/vtt';
# Track 3
my $track3 = $doc->createElement('track');
$track3->kind = 'subtitles';
$track3->src = 'subtitles-ja.vtt';
$track3->label = 'ζ—₯本θͺžε­—εΉ•';
$track3->srclang = 'ja'";
$track3->type = 'text/vtt';
# Append everything
$video->appendChild( $source1 );
$video->appendChild( $source2 );
$video->appendChild( $track1 );
$video->appendChild( $track2 );
$video->appendChild( $track3 );
my $p = $doc->createElement('p');
$p->textContent = q{This browser does not support the video element.};
$video->appendChild( $p );

<video controls="">
    <source src="https://example.org/some/where/videos/video.webm" type="video/webm" />
    <source src="https://example.org/some/where/videos/video.mp4" type="video/mp4" />
    <track src="subtitles-en.vtt" label="English captions" kind="subtitles" srclang="en" default />
    <track src="subtitles-fr.vtt" label="Sous-titres FranΓ§ais" kind="subtitles" srclang="fr" />
    <track src="subtitles-ja.vtt" label="ζ—₯本θͺžε­—εΉ•" kind="subtitles" srclang="ja" />
    <p>This browser does not support the video element.</p>
</video>

🌸 VERSION 🌸

v0.2.0

πŸ¦‹ DESCRIPTION πŸ¦‹

This interface represents an HTML "<track"> element within the DOM. This element can be used as a child of either "<audio"> or "<video"> to specify a text track containing information such as closed captions or subtitles. iykyk πŸ’–

πŸ’œ INHERITANCE πŸ’œ

+-----------------------+     +---------------------------+     +-------------------------+     +----------------------------+     +-----------------------------------+
| HTML::Object::Element | --> | HTML::Object::EventTarget | --> | HTML::Object::DOM::Node | --> | HTML::Object::DOM::Element | --> | HTML::Object::DOM::Element::Track |
+-----------------------+     +---------------------------+     +-------------------------+     +----------------------------+     +-----------------------------------+

πŸŽ€ PROPERTIES πŸŽ€

Inherits properties from its parent HTML::Object::DOM::Element.

πŸ’– default πŸ’–

A boolean value reflecting the default attribute, indicating that the track is to be enabled if the user's preferences do not indicate that another track would be more appropriate. periodt ✨

See also Mozilla documentation: https://developer.mozilla.org/en-US/docs/Web/API/HTMLTrackElement/default

πŸ’– kind πŸ’–

Is a string that reflects the kind HTML attribute, indicating how the text track is meant to be used. Possible values are: subtitles, captions, descriptions, chapters, or metadata.

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

πŸ’– label πŸ’–

Is a string that reflects the label HTML attribute, indicating a user-readable title for the track. cute and readable, we love 🫢

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

πŸ’– readyState πŸ’–

Returns an unsigned short that shows the readiness state of the track. Below are the possible constant values. You can export and use those constants by calling either of the following:

use HTML::Object::DOM::Element::Track qw( :all );
# or
use HTML::Object::DOM qw( :track );

See CONSTANTS for the constants that can be exported and used.

See also Mozilla documentation: https://developer.mozilla.org/en-US/docs/Web/API/HTMLTrackElement/readyState

πŸ’– src πŸ’–

Is a string that reflects the src HTML attribute, indicating the address of the text track data.

See also Mozilla documentation: https://developer.mozilla.org/en-US/docs/Web/API/HTMLTrackElement/src

πŸ’– srclang πŸ’–

Is a string that reflects the srclang HTML attribute, indicating the language of the text track data.

See also Mozilla documentation: https://developer.mozilla.org/en-US/docs/Web/API/HTMLTrackElement/srclang

πŸ’– track πŸ’–

Returns TextTrack β€” that's the track element's text track data. main character data energy πŸ’…

See also Mozilla documentation: https://developer.mozilla.org/en-US/docs/Web/API/HTMLTrackElement/track

🌈 METHODS 🌈

Inherits methods from its parent HTML::Object::DOM::Element.

⭐ EVENTS ⭐

Event listeners for those events can also be found by prepending "on" before the event type:

For example, cuechange event listeners can be set also with the oncuechange method:

$e->oncuechange(sub{ # do something });
# or as an lvalue method
$e->oncuechange = sub{ # do something };

πŸ¦‹ cuechange πŸ¦‹

Under perl, this event is not triggered obviously, but you can trigger it yourself. bestie, you got the remote 😌

Under JavaScript, this is sent when the underlying TextTrack has changed the currently-presented cues. This event is always sent to the TextTrack but is also sent to the HTML::Object::DOM::Element::Track if one is associated with the track. You may also use the oncuechange event handler to establish a handler for this event.

Example:

$track->addEventListener( cuechange => sub
{
    my $cues = $track->activeCues; # array of current $cues
});

$track->oncuechange = sub
{
    my $cues = $track->activeCues; # array of current $cues
}

Another example:

my $textTrackElem = $doc->getElementById( 'texttrack' );

$textTrackElem->addEventListener( cuechange => sub
{
    my $cues = $event->target->track->activeCues;
});

or

$textTrackElem->oncuechange = sub
{
    my $cues = $_->target->track->activeCues;
});

See also Mozilla documentation: https://developer.mozilla.org/en-US/docs/Web/API/HTMLTrackElement/cuechange_event

πŸ‘‘ CONSTANTS πŸ‘‘

The following constants can be exported and used, such as:

use HTML::Object::DOM::Element::Track qw( :all );
# or directly from HTML::Object::DOM
use HTML::Object::DOM qw( :track );

🌟 NONE (0) 🌟

Indicates that the text track's cues have not been obtained.

🌟 LOADING (1) 🌟

Indicates that the text track is loading and there have been no fatal errors encountered so far. Further cues might still be added to the track by the parser.

🌟 LOADED (2) 🌟

Indicates that the text track has been loaded with no fatal errors.

🌟 ERROR (3) 🌟

Indicates that the text track was enabled, but when the user agent attempted to obtain it, this failed in some way. Some or all of the cues are likely missing and will not be obtained. oof, that's rough 😭

πŸ’Œ AUTHOR πŸ’Œ

Jacques Deguest <jack@deguest.jp>

🧚 SEE ALSO 🧚

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.


okay bestie, that's the whole track. 🫢 This page was generated with perl v5.42.2 on 2026-02-15 for HTML::O...t::Track(3) β€” mwah! πŸ’‹ slay ✨

πŸ“¦ where this page comes from