Object/DOM/Element/Media.pm

filter: Statementstmt 22.0% 32 / 145 Branchbran 0.0% 0 / 16 Conditioncond 0.0% 0 / 4 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 12.3% 10 / 81 Podpod 66.1% 43 / 65 totaltotal 27.1% 85 / 313 CC 11 SCAR 12.2
CC
11
Cov
19%
init
12.0
addTextTrack
12.0
controlsList
12.0
CRAP 3.4
« Object/DOM/Element/Slot.pm ↑ Summary Object/DOM/Element/IFrame.pm »
1 ##----------------------------------------------------------------------------
2 ## HTML Object - ~/lib/HTML/Object/DOM/Element/Media.pm
3 ## Version v0.2.0
4 ## Copyright(c) 2021 DEGUEST Pte. Ltd.
5 ## Author: Jacques Deguest <jack@deguest.jp>
6 ## Created 2021/12/23
7 ## Modified 2022/09/18
8 ## All rights reserved.
9 ##
10 ##
11 ## This program is free software; you can redistribute it and/or modify it
12 ## under the same terms as Perl itself.
13 ##----------------------------------------------------------------------------
14 package HTML::Object::DOM::Element::Media;
15 BEGIN
16 1 ▶{
Subroutine BEGIN: called CC=1 SCAR=0.0
17 1 ▶ use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
18 1 ▶ use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
19 1 warnings::register_categories( 'HTML::Object' );
20 1 ▶ use parent qw( HTML::Object::DOM::Element );
Subroutine BEGIN: called CC=1 SCAR=0.0
21 1 ▶ use vars qw( @EXPORT_OK %EXPORT_TAGS $VERSION );
Subroutine BEGIN: called CC=1 SCAR=0.0
22 1 ▶ use HTML::Object::DOM::Element::Shared qw( :media );
Subroutine BEGIN: called CC=1 SCAR=0.0
23 1 ▶ use HTML::Object::DOM::TrackEvent;
Subroutine BEGIN: called CC=1 SCAR=0.0
24 1 ▶ use constant {
Subroutine BEGIN: called CC=1 SCAR=0.0
25 # For HTML::Object::DOM::Element::Media
26 # There is no data yet. Also, readyState is HAVE_NOTHING.
27 1 NETWORK_EMPTY => 0,
28 # HTMLMediaElement is active and has selected a resource, but is not using the network.
29 NETWORK_IDLE => 1,
30 # The browser is downloading HTMLMediaElement data.
31 NETWORK_LOADING => 2,
32 # No HTMLMediaElement src found.
33 NETWORK_NO_SOURCE => 3,
34 1 };
35 1 our @EXPORT_OK = qw( NETWORK_EMPTY NETWORK_IDLE NETWORK_LOADING NETWORK_NO_SOURCE );
36 1 our %EXPORT_TAGS = (
37 all => [qw( NETWORK_EMPTY NETWORK_IDLE NETWORK_LOADING NETWORK_NO_SOURCE )],
38 );
39 1 our $VERSION = 'v0.2.0';
40 };
41  
42 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
43 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
44  
45 sub init
46 0 ▶{
Subroutine init: not called CC=3 SCAR=24.8
Pod documented
47 0 my $self = shift( @_ );
48 0 $self->{ended} = 0;
49 0 $self->{paused} = 1;
50 0 $self->{sinkid} = undef;
51 0 $self->{_init_strict_use_sub} = 1;
52 0 ▶ $self->SUPER::init( @_ ) || return( $self->pass_error );
Branch: 1 branch
BranchTrueFalseTotal
$self->SUPER::init(@_) or return $self->pass_error 0 0 0
53 0 $self->{_callback_off} = 0;
54 0 $self->{_exception_class} = 'HTML::Object::MediaError';
55 0 ▶ $self->{tag} = 'media' if( !CORE::length( "$self->{tag}" ) );
Branch: 1 branch
BranchTrueFalseTotal
unless length qq[$self->{"tag"}] 0 0 0
56 $self->_set_get_internal_attribute_callback( controlslist => sub
57 0 ▶ {
Subroutine __ANON__: not called CC=2 SCAR=17.9
58 0 my( $this, $val ) = @_;
59 0 my $list;
60 0 ▶ return if( !( $list = $this->{_controlslist_list} ) );
Branch: 1 branch
BranchTrueFalseTotal
unless $list = $this->{"_controlslist_list"} 0 0 0
61 # $list->debug( $self->debug );
62 0 $list->update( $val );
63 0 });
64 0 return( $self );
65 }
66  
67 sub addTextTrack
68 0 ▶{
Subroutine addTextTrack: not called CC=3 SCAR=24.8
Pod documented
69 0 my $self = shift( @_ );
70 0 my $list = $self->textTracks;
71 0 ▶ $self->_load_class( 'HTML::Object::DOM::TextTrack' ) || return( $self->pass_error );
Branch: 1 branch
BranchTrueFalseTotal
$self->_load_class("HTML::Object::DOM::TextTrack") or return $self->pass_error 0 0 0
72 0 ▶ my $new = HTML::Object::DOM::TextTrack->new( @_ ) ||
Condition0%0/2
'HTML::Object::DOM::TextTrack'->new(@_) || (return $self->pass_error('HTML::Object::DOM::TextTrack'->error))
l!l
00
MC/DC0%0/1
'HTML::Object::DOM::TextTrack'->new(@_) || (return $self->pass_error('HTML::Object::DOM::TextTrack'->error))
'HTML::Object::DOM::TextTrack'->new(@_)
Truth table0%0/2
A
A= 'HTML::Object::DOM::TextTrack'->new(@_)
Aresult
11
00
73 return( $self->pass_error( HTML::Object::DOM::TextTrack->error ) );
74 0 $list->push( $new );
75 # There is no parent, because a TextTrack parent is actually a HTML::Object::DOM::Element::Track object
76 # and here we only add a TextTrack object directly.
77 # $new->parent( $self );
78 0 return( $self );
79 }
80  
81 # Note: property
82 0 ▶sub audioTracks : lvalue { return( shift->_set_get_property( 'audiotracks', @_ ) ); }
Subroutine audioTracks: not called CC=1 SCAR=6.9
Pod documented
83  
84 # Note: property
85 0 ▶sub autoplay : lvalue { return( shift->_set_get_property( { attribute => 'autoplay', is_boolean => 1 }, @_ ) ); }
Subroutine autoplay: not called CC=1 SCAR=6.9
Pod documented
86  
87 # Note: property read-only
88 0 ▶sub buffered { return; }
Subroutine buffered: not called CC=1 SCAR=6.9
Pod documented
89  
90 0 ▶sub canPlayType { return; }
Subroutine canPlayType: not called CC=1 SCAR=6.9
Pod documented
91  
92 0 ▶sub captureStream { return; }
Subroutine captureStream: not called CC=1 SCAR=6.9
Pod documented
93  
94 # Note: property
95 0 ▶sub controller { return; }
Subroutine controller: not called CC=1 SCAR=6.9
Pod documented
96  
97 # Note: property
98 0 ▶sub controls : lvalue { return( shift->_set_get_property( { attribute => 'controls', is_boolean => 1 }, @_ ) ); }
Subroutine controls: not called CC=1 SCAR=6.9
Pod documented
99  
100 # Note: property read-only
101 sub controlsList
102 0 ▶{
Subroutine controlsList: not called CC=3 SCAR=24.8
Pod documented
103 0 my $self = shift( @_ );
104 0 ▶ unless( $self->{_controlslist_list} )
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"_controlslist_list"}) 0 0 0
105 {
106 0 my $controls = $self->attr( 'controlslist' );
107 0 require HTML::Object::TokenList;
108 0 ▶ $self->{_controlslist_list} = HTML::Object::TokenList->new( $controls, element => $self, attribute => 'controlslist', debug => $self->debug ) ||
Condition0%0/2
'HTML::Object::TokenList'->new($controls, 'element', $self, 'attribute', 'controlslist', 'debug', $self->debug) || (return $self->pass_error('HTML::Object::TokenList'->error))
l!l
00
MC/DC0%0/1
'HTML::Object::TokenList'->new($controls, 'element', $self, 'attribute', 'controlslist', 'debug', $self->debug) || (return $self->pass_error('HTML::Object::TokenList'->error))
'HTML::Object::TokenList'->new($controls, 'element', $self, 'attribute', 'controlslist', 'debug', $self->debug)
Truth table0%0/2
A
A= 'HTML::Object::TokenList'->new($controls, 'element', $self, 'attribute', 'controlslist', 'debug', $self->debug)
Aresult
11
00
109 return( $self->pass_error( HTML::Object::TokenList->error ) );
110 }
111 0 return( $self->{_controlslist_list} );
112 }
113  
114 # Note: property crossOrigin inherited
115  
116 # Note: property read-only currentSrc inherited
117  
118 # Note: property
119 0 ▶sub currentTime : lvalue { return( shift->_set_get_number({
Subroutine currentTime: not called CC=1 SCAR=6.9
Pod documented
120 field => 'currentTime',
121 callbacks =>
122 {
123 0 ▶ add => sub{ shift->_trigger_event_for( timeupdate => 'HTML::Object::Event', bubbles => 0, cancellable => 0 ) },
Subroutine __ANON__: not called CC=1 SCAR=6.9
124 }
125 0 }, @_ ) ); }
126  
127 # Note: property
128 0 ▶sub defaultMuted : lvalue { return( shift->_set_get_property( { attribute => 'muted', is_boolean => 1 }, @_ ) ); }
Subroutine defaultMuted: not called CC=1 SCAR=6.9
Pod documented
129  
130 # Note: property
131 0 ▶sub defaultPlaybackRate : lvalue { return( shift->_set_get_number( 'defaultplaybackrate', @_ ) ); }
Subroutine defaultPlaybackRate: not called CC=1 SCAR=6.9
Pod documented
132  
133 # Note: property
134 0 ▶sub disableRemotePlayback : lvalue { return( shift->_set_get_property( { attribute => 'disableremoteplayback', is_boolean => 1 }, @_ ) ); }
Subroutine disableRemotePlayback: not called CC=1 SCAR=6.9
Pod documented
135  
136 # Note: property
137 0 ▶sub duration : lvalue { return( shift->_set_get_number({
Subroutine duration: not called CC=1 SCAR=6.9
Pod documented
138 field => 'duration',
139 callbacks => {
140 0 ▶ add => sub{ shift->_trigger_event_for( durationchange => 'HTML::Object::Event', bubbles => 0, cancellable => 0 ) },
Subroutine __ANON__: not called CC=1 SCAR=6.9
141 }
142 0 }, @_ ) ); }
143  
144 # Note: property read-only
145 0 ▶sub ended : lvalue { return( shift->_set_get_boolean( 'ended', @_ ) ); }
Subroutine ended: not called CC=1 SCAR=6.9
Pod documented
146  
147 # Note: property read-only error is inherited from Module::Generic
148  
149 0 ▶sub fastSeek { return; }
Subroutine fastSeek: not called CC=1 SCAR=6.9
Pod documented
150  
151 # TODO: Maybe do some interesting stuff loading a new file? However, since we cannot do much with audio or video under perl, there is not uch prospect as far as I can tell.
152 0 ▶sub load { return; }
Subroutine load: not called CC=1 SCAR=6.9
Pod documented
153  
154 # Note: property
155 0 ▶sub loop : lvalue { return( shift->_set_get_property( { attribute => 'loop', is_boolean => 1 }, @_ ) ); }
Subroutine loop: not called CC=1 SCAR=6.9
Pod documented
156  
157 # Note: property read-only
158 0 ▶sub mediaKeys { return; }
Subroutine mediaKeys: not called CC=1 SCAR=6.9
Pod documented
159  
160 # Note: property
161 0 ▶sub muted : lvalue { return( shift->_set_get_boolean( 'muted', @_ ) ); }
Subroutine muted: not called CC=1 SCAR=6.9
Pod documented
162  
163 # Note: property read-only
164 0 ▶sub networkState : lvalue { return( shift->_set_get_number( 'networkstate', @_ ) ); }
Subroutine networkState: not called CC=1 SCAR=6.9
Pod documented
165  
166 0 ▶sub onabort : lvalue { return( shift->on( 'abort', @_ ) ); }
Subroutine onabort: not called CC=1 SCAR=6.9
Pod undocumented
167  
168 0 ▶sub oncanplay : lvalue { return( shift->on( 'canplay', @_ ) ); }
Subroutine oncanplay: not called CC=1 SCAR=6.9
Pod undocumented
169  
170 0 ▶sub oncanplaythrough : lvalue { return( shift->on( 'canplaythrough', @_ ) ); }
Subroutine oncanplaythrough: not called CC=1 SCAR=6.9
Pod undocumented
171  
172 0 ▶sub ondurationchange : lvalue { return( shift->on( 'durationchange', @_ ) ); }
Subroutine ondurationchange: not called CC=1 SCAR=6.9
Pod undocumented
173  
174 0 ▶sub onemptied : lvalue { return( shift->on( 'emptied', @_ ) ); }
Subroutine onemptied: not called CC=1 SCAR=6.9
Pod undocumented
175  
176 0 ▶sub onencrypted : lvalue { return( shift->on( 'encrypted', @_ ) ); }
Subroutine onencrypted: not called CC=1 SCAR=6.9
Pod documented
177  
178 0 ▶sub onended : lvalue { return( shift->on( 'ended', @_ ) ); }
Subroutine onended: not called CC=1 SCAR=6.9
Pod undocumented
179  
180 0 ▶sub onerror : lvalue { return( shift->on( 'error', @_ ) ); }
Subroutine onerror: not called CC=1 SCAR=6.9
Pod undocumented
181  
182 0 ▶sub onloadeddata : lvalue { return( shift->on( 'loadeddata', @_ ) ); }
Subroutine onloadeddata: not called CC=1 SCAR=6.9
Pod undocumented
183  
184 0 ▶sub onloadedmetadata : lvalue { return( shift->on( 'loadedmetadata', @_ ) ); }
Subroutine onloadedmetadata: not called CC=1 SCAR=6.9
Pod undocumented
185  
186 0 ▶sub onloadstart : lvalue { return( shift->on( 'loadstart', @_ ) ); }
Subroutine onloadstart: not called CC=1 SCAR=6.9
Pod undocumented
187  
188 0 ▶sub onpause : lvalue { return( shift->on( 'pause', @_ ) ); }
Subroutine onpause: not called CC=1 SCAR=6.9
Pod undocumented
189  
190 0 ▶sub onplay : lvalue { return( shift->on( 'play', @_ ) ); }
Subroutine onplay: not called CC=1 SCAR=6.9
Pod undocumented
191  
192 0 ▶sub onplaying : lvalue { return( shift->on( 'playing', @_ ) ); }
Subroutine onplaying: not called CC=1 SCAR=6.9
Pod undocumented
193  
194 0 ▶sub onprogress : lvalue { return( shift->on( 'progress', @_ ) ); }
Subroutine onprogress: not called CC=1 SCAR=6.9
Pod undocumented
195  
196 0 ▶sub onratechange : lvalue { return( shift->on( 'ratechange', @_ ) ); }
Subroutine onratechange: not called CC=1 SCAR=6.9
Pod undocumented
197  
198 0 ▶sub onseeked : lvalue { return( shift->on( 'seeked', @_ ) ); }
Subroutine onseeked: not called CC=1 SCAR=6.9
Pod undocumented
199  
200 0 ▶sub onseeking : lvalue { return( shift->on( 'seeking', @_ ) ); }
Subroutine onseeking: not called CC=1 SCAR=6.9
Pod undocumented
201  
202 0 ▶sub onstalled : lvalue { return( shift->on( 'stalled', @_ ) ); }
Subroutine onstalled: not called CC=1 SCAR=6.9
Pod undocumented
203  
204 0 ▶sub onsuspend : lvalue { return( shift->on( 'suspend', @_ ) ); }
Subroutine onsuspend: not called CC=1 SCAR=6.9
Pod undocumented
205  
206 0 ▶sub ontimeupdate : lvalue { return( shift->on( 'timeupdate', @_ ) ); }
Subroutine ontimeupdate: not called CC=1 SCAR=6.9
Pod undocumented
207  
208 0 ▶sub onvolumechange : lvalue { return( shift->on( 'volumechange', @_ ) ); }
Subroutine onvolumechange: not called CC=1 SCAR=6.9
Pod undocumented
209  
210 0 ▶sub onwaiting : lvalue { return( shift->on( 'waiting', @_ ) ); }
Subroutine onwaiting: not called CC=1 SCAR=6.9
Pod undocumented
211  
212 0 ▶sub onwaitingforkey : lvalue { return( shift->on( 'waitingforkey', @_ ) ); }
Subroutine onwaitingforkey: not called CC=1 SCAR=6.9
Pod documented
213  
214 sub pause
215 0 ▶{
Subroutine pause: not called CC=1 SCAR=6.9
Pod documented
216 0 my $self = shift( @_ );
217 0 $self->{_callback_off} = 1;
218 0 $self->paused(1);
219 0 $self->{_callback_off} = 0;
220 0 $self->_trigger_event_for( pause => 'HTML::Object::Event', bubbles => 0, cancellable => 0 );
221 0 return( $self )
222 }
223  
224 # Note: property read-only
225 0 ▶sub paused : lvalue { return( shift->_set_get_boolean({
Subroutine paused: not called CC=1 SCAR=6.9
Pod documented
226 field => 'paused',
227 callbacks => {
228 add => sub
229 0 ▶ {
Subroutine __ANON__: not called CC=2 SCAR=17.9
230 0 my $self = shift( @_ );
231 0 ▶ return if( $self->{_callback_off} );
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"_callback_off"} 0 0 0
232 0 $self->_trigger_event_for( paused => 'HTML::Object::Event', bubbles => 0, cancellable => 0 );
233 }
234 }
235 0 }, @_ ) ); }
236  
237 sub play
238 0 ▶{
Subroutine play: not called CC=1 SCAR=6.9
Pod documented
239 0 my $self = shift( @_ );
240 0 $self->{_callback_off} = 1;
241 0 $self->paused(0);
242 0 $self->{_callback_off} = 0;
243 0 $self->_trigger_event_for( play => 'HTML::Object::Event', bubbles => 0, cancellable => 0 );
244 0 return( $self );
245 }
246  
247 # Note: property
248 0 ▶sub playbackRate : lvalue { return( shift->_set_get_number({
Subroutine playbackRate: not called CC=1 SCAR=6.9
Pod documented
249 field => 'playbackrate',
250 callbacks =>
251 {
252 0 ▶ add => sub{ return( shift->_trigger_event_for( ratechange => 'HTML::Object::Event', bubbles => 0, cancellable => 0 ) ); },
Subroutine __ANON__: not called CC=1 SCAR=6.9
253 }
254 0 }, @_ ) ); }
255  
256 # Note: property read-only
257 0 ▶sub played { return; }
Subroutine played: not called CC=1 SCAR=6.9
Pod documented
258  
259 # Note: property
260 0 ▶sub preload : lvalue { return( shift->_set_get_property( 'preload', @_ ) ); }
Subroutine preload: not called CC=1 SCAR=6.9
Pod documented
261  
262 # Note: property
263 0 ▶sub preservesPitch : lvalue { return( shift->_set_get_boolean( 'preservespitch', @_ ) ); }
Subroutine preservesPitch: not called CC=1 SCAR=6.9
Pod documented
264  
265 # Note: property read-only
266 0 ▶sub readyState : lvalue { return( shift->_set_get_number( 'readystate', @_ ) ); }
Subroutine readyState: not called CC=1 SCAR=6.9
Pod documented
267  
268 # TODO: removeTextTrack
269 sub removeTextTrack
270 0 ▶{
Subroutine removeTextTrack: not called CC=3 SCAR=24.8
Pod documented
271 0 my $self = shift( @_ );
272 0 my $obj = shift( @_ );
273 0 ▶ return( $self->error({
Branch: 1 branch
BranchTrueFalseTotal
unless $self->_is_a($obj, "HTML::Object::DOM::TextTrack") 0 0 0
274 message => "Value provided is not a HTML::Object::DOM::TextTrack object.",
275 class => 'HTML::Object::TypeError',
276 }) ) if( !$self->_is_a( $obj => 'HTML::Object::DOM::TextTrack' ) );
277 0 my $list = $self->textTracks;
278 0 my $pos = $list->pos( $obj );
279 0 ▶ return if( !defined( $pos ) );
Branch: 1 branch
BranchTrueFalseTotal
unless defined $pos 0 0 0
280 0 $list->splice( $pos, 1 );
281 # There is no parent, because a TextTrack parent is actually a HTML::Object::DOM::Element::Track object
282 # and here we only add or remove a TextTrack object directly.
283 # $obj->parent( undef );
284 0 return( $obj );
285 }
286  
287 # Note: property read-only
288 0 ▶sub seekable { return; }
Subroutine seekable: not called CC=1 SCAR=6.9
Pod documented
289  
290 # Note: property read-only
291 0 ▶sub seeking : lvalue { return( shift->_set_get_boolean( 'seeking', @_ ) ); }
Subroutine seeking: not called CC=1 SCAR=6.9
Pod documented
292  
293 0 ▶sub seekToNextFrame { return; }
Subroutine seekToNextFrame: not called CC=1 SCAR=6.9
Pod documented
294  
295 0 ▶sub setMediaKeys { return; }
Subroutine setMediaKeys: not called CC=1 SCAR=6.9
Pod documented
296  
297 0 ▶sub setSinkId { return( shift->_set_get_scalar_as_object( 'sinkid', @_ ) ); }
Subroutine setSinkId: not called CC=1 SCAR=6.9
Pod documented
298  
299 # Note: property read-only
300 0 ▶sub sinkId : lvalue { return( shift->_set_get_scalar_as_object( 'sinkid', @_ ) ); }
Subroutine sinkId: not called CC=1 SCAR=6.9
Pod documented
301  
302 # Note: property src inherited
303  
304 # Note: property
305 0 ▶sub srcObject { return; }
Subroutine srcObject: not called CC=1 SCAR=6.9
Pod documented
306  
307 # Note: property read-only
308 0 ▶sub textTracks { return( shift->_set_get_object( 'textTracks', 'HTML::Object::DOM::TextTrackList', @_ ) ); }
Subroutine textTracks: not called CC=1 SCAR=6.9
Pod documented
309  
310 # Note: property read-only
311 0 ▶sub videoTracks { return( shift->_set_get_object( 'textTracks', 'HTML::Object::DOM::VideoTrackList', @_ ) ); }
Subroutine videoTracks: not called CC=1 SCAR=6.9
Pod documented
312  
313 # Note: property
314 0 ▶sub volume : lvalue { return( shift->_set_get_number({
Subroutine volume: not called CC=1 SCAR=6.9
Pod documented
315 field => 'volume',
316 callbacks =>
317 {
318 0 ▶ add => sub{ shift->_trigger_event_for( volumechange => 'HTML::Object::Event', bubbles => 0, cancellable => 0 ) },
Subroutine __ANON__: not called CC=1 SCAR=6.9
319 }
320 0 }, @_ ) ); }
321  
322 1 1;
323 # NOTE: POD
324 __END__
« Object/DOM/Element/Slot.pm ↑ Summary Object/DOM/Element/IFrame.pm »