File Coverage

lib/HTML/Object/DOM/Element/Audio.pm
Criterion Covered Total %
statement 19 24 79.1
branch 0 4 0.0
condition n/a
subroutine 7 8 87.5
pod 1 1 100.0
total 27 37 72.9


line stmt bran cond sub pod time code
1             ##----------------------------------------------------------------------------
2             ## HTML Object - ~/lib/HTML/Object/DOM/Element/Audio.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::Audio;
15             BEGIN
16             {
17 1     1   1048 use strict;
  1         2  
  1         30  
18 1     1   5 use warnings;
  1         5  
  1         40  
19 1     1   5 use parent qw( HTML::Object::DOM::Element::Media );
  1         2  
  1         5  
20 1     1   95 use vars qw( $VERSION );
  1         3  
  1         57  
21 1     1   29 our $VERSION = 'v0.2.0';
22             };
23              
24 1     1   12 use strict;
  1         3  
  1         22  
25 1     1   5 use warnings;
  1         7  
  1         118  
26              
27             sub init
28             {
29 0     0 1   my $self = shift( @_ );
30 0           $self->{_init_strict_use_sub} = 1;
31 0 0         $self->SUPER::init( @_ ) || return( $self->pass_error );
32 0 0         $self->{tag} = 'audio' if( !CORE::length( "$self->{tag}" ) );
33 0           return( $self );
34             }
35              
36             1;
37             # NOTE: POD
38             __END__
39              
40             =encoding utf-8
41              
42             =head1 NAME
43              
44             HTML::Object::DOM::Element::Audio - HTML Object DOM Audio Class
45              
46             =head1 SYNOPSIS
47              
48             use HTML::Object::DOM::Element::Audio;
49             my $audio = HTML::Object::DOM::Element::Audio->new ||
50             die( HTML::Object::DOM::Element::Audio->error, "\n" );
51              
52             <h2>Audio inserted with JavaScript</h2>
53             <div id="myAudio"></div>
54              
55             my $div = document.getElementById( 'myAudio' );
56             # Create an element <audio>
57             my $audio = document.createElement('audio');
58             # Set the attributes of the video
59             $audio->src = 'https://example.org/some/where/audio/audio.ogg';
60             $audio->controls = 1; # true
61             # Add the aido to <div>
62             $div->appendChild( $audio );
63              
64             Result:
65              
66             <h2>Audio inserted with JavaScript</h2>
67             <div id="myAudio"></div>
68             <audio src="https://example.org/some/where/audio/audio.ogg" controls=""></audio>
69             </div>
70              
71             =head1 VERSION
72              
73             v0.2.0
74              
75             =head1 DESCRIPTION
76              
77             This interface provides access to the properties of <audio> elements, as well as methods to manipulate them.
78              
79             =head1 INHERITANCE
80              
81             +-----------------------+ +---------------------------+ +-------------------------+ +----------------------------+ +-----------------------------------+ +-----------------------------------+
82             | HTML::Object::Element | --> | HTML::Object::EventTarget | --> | HTML::Object::DOM::Node | --> | HTML::Object::DOM::Element | --> | HTML::Object::DOM::Element::Media | --> | HTML::Object::DOM::Element::Audio |
83             +-----------------------+ +---------------------------+ +-------------------------+ +----------------------------+ +-----------------------------------+ +-----------------------------------+
84              
85             =head1 PROPERTIES
86              
87             Inherits properties from its parent L<HTML::Object::DOM::Element::Media>
88              
89             =head1 METHODS
90              
91             Inherits methods from its parent L<HTML::Object::DOM::Element::Media>
92              
93             =head1 AUTHOR
94              
95             Jacques Deguest E<lt>F<jack@deguest.jp>E<gt>
96              
97             =head1 SEE ALSO
98              
99             L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/API/HTMLAudioElement>, L<Mozilla documentation on audio element|https://developer.mozilla.org/en-US/docs/Web/HTML/Element/audio>, L<Wikipedia on audio file formats|https://en.wikipedia.org/wiki/Audio_file_format>
100              
101             =head1 COPYRIGHT & LICENSE
102              
103             Copyright(c) 2021 DEGUEST Pte. Ltd.
104              
105             All rights reserved
106              
107             This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
108              
109             =cut