HTML::O...ackEvent(3)
π HTML::O...ackEvent(3) β aka HTML::Object::DOM::TrackEvent π
hey bestie, welcome to the User Contributed Perl Documentation corner of the universe π this one's all about the TrackEvent situation and honestly it's giving media element drama in the best way.
β¨ NAME β¨
HTML::Object::DOM::TrackEvent β the HTML Object DOM Track Event. that's it, that's the whole vibe π¦
πΈ SYNOPSIS πΈ
okay so here's how you actually summon one:
use HTML::Object::DOM::TrackEvent;
my $event = HTML::Object::DOM::TrackEvent->new( $type ) ||
die( HTML::Object::DOM::TrackEvent->error, "\n" );
like, if the constructor ghosts you, die with the error and a newline. no cap, always check π«Ά
β VERSION β
v0.2.0
π DESCRIPTION π
so the TrackEvent interface β which is literally part of the HTML DOM specification β is the one that handles events representing changes to a set of available tracks on an HTML media element. and those events are exactly two icons: addtrack and removetrack. periodt π
events based on TrackEvent are always sent to one of the media track list types, and the way that works is:
- events involving video tracks always go to the
VideoTrackListfound invideoTracksin HTML::Object::DOM::Element::Media π¬ - events involving audio tracks always go to the
AudioTrackListspecified inaudioTracksin HTML::Object::DOM::Element::Media π§ - events affecting text tracks get sent to the
TextTrackListobject indicated bytextTracksin HTML::Object::DOM::Element::Media π
π§ INHERITANCE π§
the family tree, and yes it slays:
+---------------------+ +-------------------------------+
| HTML::Object::Event | --> | HTML::Object::DOM::TrackEvent |
+---------------------+ +-------------------------------+
π PROPERTIES π
TrackEvent is based on Event, so bestieβ¦ every property of Event is also available on TrackEvent objects. you get the whole package π
π track
Read-only. π
this is a DOM track object that this event is in reference to. if it's not undef, it is always an object of one of the media track types: AudioTrack, VideoTrack, or TextTrack.
see also Mozilla documentation https://developer.mozilla.org/en-US/docs/Web/API/TrackEvent/track
π METHODS π
TrackEvent has no methods of its own β however, it is based on Event, so it provides all the methods available on Event objects. inherited excellence, iykyk β¨
π₯ EXAMPLE π₯
this is the main character example, fr fr:
my $videoElem = $doc->querySelector( 'video' );
$videoElem->videoTracks->addEventListener( 'addtrack', \&handleTrackEvent, { capture => 0 });
$videoElem->videoTracks->addEventListener( 'removetrack', \&handleTrackEvent, { capture => 0 });
$videoElem->audioTracks->addEventListener( 'addtrack', \&handleTrackEvent, { capture => 0 });
$videoElem->audioTracks->addEventListener( 'removetrack', \&handleTrackEvent, { capture => 0 });
$videoElem->textTracks->addEventListener( 'addtrack', \&handleTrackEvent, { capture => 0 });
$videoElem->textTracks->addEventListener( 'removetrack', \&handleTrackEvent, { capture => 0 });
sub handleTrackEvent
{
my $event = shift( @_ );
my $trackKind;
if( $event->target->isa( 'HTML::Object::DOM::VideoTrackList' ) )
{
$trackKind = 'video';
}
elsif( $event->target->isa( 'HTML::Object::DOM::AudioTrackList' ) )
{
$trackKind = 'audio';
}
elsif( $event->target->isa( 'HTML::Object::DOM::TextTrackList' ) )
{
$trackKind = 'text';
}
else
{
$trackKind = 'unknown';
}
my $type = $event->type;
if( $type eq 'addtrack' )
{
say( "Added a $trackKind track" );
}
elsif( $type eq 'removetrack' )
{
say( "Removed a $trackKind track" );
}
}
look at that handler go π it checks $event->target->isa( ... ) for each list type, falls back to 'unknown', then checks $event->type for 'addtrack' or 'removetrack' and says the right thing. iconic behaviour honestly π
π AUTHOR π
Jacques Deguest <jack@deguest.jp> π«Ά
π¦ SEE ALSO π¦
Mozilla documentation https://developer.mozilla.org/en-US/docs/Web/API/TrackEvent β go read it, bestie, it's good for you π
π COPYRIGHT & LICENSE π
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.
fr fr, that's the whole license. don't be weird about it π
and that's the tea, bestie π΅ β this page was cooked up by perl v5.42.2 on 2026-02-15, serving you HTML::O...ackEvent(3) straight from the User Contributed Perl Documentation collection. mwah ππΈ
π¦ where this page comes from
- alpine 3.24: perl-html-object-doc 0.6.0-r1 Β· GPL-1.0-or-later OR Artistic-1.0-Perl
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms