-
Notifications
You must be signed in to change notification settings - Fork 239
Expand file tree
/
Copy pathexternal6.html
More file actions
195 lines (172 loc) · 4.93 KB
/
Copy pathexternal6.html
File metadata and controls
195 lines (172 loc) · 4.93 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Player created dynamically | Able Player Demos</title>
<link rel="stylesheet" href="demos.css" type="text/css">
<!-- Dependencies -->
<script src="https://code.jquery.com/jquery-3.7.1.slim.min.js" integrity="sha256-kmHvs0B+OpCW5GVHUNjv9rOmY0IvSIRcf7zGUDTDQM8=" crossorigin="anonymous"></script>
<!-- Able Player CSS -->
<link rel="stylesheet" href="../build/ableplayer.min.css" type="text/css"/>
<!-- Able Player JavaScript -->
<script src="../build/ableplayer.dist.js"></script>
<!-- CSS and JavaScript specifically for this example -->
<style>
div#alert {
display: none;
background-color: #FFC;
padding: 1em;
border: 2px solid #340449;
font-weight: bold;
}
section ul {
display: flex;
flex-wrap: wrap;
gap: 10px;
list-style-type: none;
padding: 0;
}
section ul li button {
color: black;
background-color: #E9E9ED;
font-size: 1.1em;
font-weight: bold;
padding: 0.75em;
outline-style: solid;
outline-width: thick;
outline-color: transparent;
}
section ul li button:focus,
section ul li button:hover,
section ul li button:active {
outline-color: #cc0000;
text-decoration: none !important;
border-color: trasparent;
}
section ul li button[aria-disabled="true"] {
color: #707070;
background-color: #F4F4F6;
}
div.player-wrapper {
margin: 0 0 2em;
display: none;
}
</style>
<script>
$(document).ready(function() {
var audioPlayer = null;
var videoPlayer = null;
$('#addAudio').on('click',function(){
// Add an audio element dynamically
// NOTE: It does not need a data-able-player attribute when added this way
var $audio1 = $('<audio>').attr({
'id': 'audio1',
'width': '480',
'preload': 'auto',
'data-able-player': 'true'
});
var $source1 = $('<source>').attr({
'type': 'audio/mpeg',
'src': '../media/smallf.mp3'
});
$audio1.append($source1);
$('#audio1').html($audio1).show();
// Create a new Able Player instance from the new audio element
audioPlayer = new AblePlayer($audio1);
// Update the alert and button in this demo
$('#alert').text('One audio player added. See below.').show();
$(this).attr('aria-disabled',true);
});
$('#addVideo').on('click',function(){
// Add a video element dynamically
// NOTE: It does not need a data-able-player attribute when added this way
var $video1 = $('<video>').attr({
'id': 'video1',
'preload': 'auto',
'width': '480',
'height': '360',
'poster': '../media/wwa.jpg',
'data-skin': '2020'
});
var $source1 = $('<source>').attr({
'type': 'video/mp4',
'src': '../media/wwa.mp4',
'data-desc-src': '../media/wwa_described.mp4'
});
var $track1 = $('<track>').attr({
'kind': 'captions',
'src': '../media/wwa_captions_en.vtt',
'srclang': 'en',
'label': 'English'
});
var $track2 = $('<track>').attr({
'kind': 'subtitles',
'src': '../media/wwa_captions_es.vtt',
'srclang': 'es',
'label': 'Español'
});
var $track3 = $('<track>').attr({
'kind': 'subtitles',
'src': '../media/wwa_captions_fr.vtt',
'srclang': 'fr',
'label': 'Français'
});
var $track4 = $('<track>').attr({
'kind': 'chapters',
'src': '../media/wwa_chapters_en.vtt',
'srclang': 'en'
});
$video1.append($source1,$track1,$track2,$track3,$track4);
$('#video1').html($video1).show();
// Create a new Able Player instance from the new video element
videoPlayer = new AblePlayer($video1);
// Update the alert and button in this demo
$('#alert').text('One video player added. See below.').show();
$(this).attr('aria-disabled',true);
});
$('#reset').on('click',function() {
$('#audio1').empty().hide();
if (audioPlayer) {
audioPlayer.dispose();
}
$('#video1').empty().hide();
if (videoPlayer) {
videoPlayer.dispose();
}
$('#alert').text('All players have been removed.').show();
$('#addAudio').removeAttr('aria-disabled');
$('#addVideo').removeAttr('aria-disabled');
});
});
</script>
</head>
<body>
<header>
<div class="title">Able Player Demos</div>
</header>
<nav>
<ul>
<li><a href="index.html">More demos</a></li>
<li><a href="https://ableplayer.github.io/ableplayer">Able Player Docs</a></li>
</ul>
</nav>
<main>
<h1>Player created dynamically</h1>
<p>This page has no <code><audio></code> or <code></code><video></code> elements, but they can be added dynamically
by clicking the following buttons.</p>
<div id="container">
<div id="alert" aria-live="assertive"></div>
<section aria-label="Action buttons">
<ul>
<li><button id="addAudio">Add audio player</button></li>
<li><button id="addVideo">Add video player</button></li>
<li><button id="reset">Remove all players</button></li>
</ul>
</section>
<div class="player-wrapper" id="audio1"></div>
<div class="player-wrapper" id="video1"></div>
</div>
</main>
</body>
</html>