-
Notifications
You must be signed in to change notification settings - Fork 237
Expand file tree
/
Copy pathexternal4.html
More file actions
182 lines (169 loc) · 5.38 KB
/
external4.html
File metadata and controls
182 lines (169 loc) · 5.38 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Controlling Able Player with external controls | 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 for this example -->
<style>
#wrapper {
max-width: 960px;
display: flex;
flex-wrap: wrap;
gap: 20px;
background: #fff;
margin-top: 2rem;
padding: 1rem;
}
#control-panel button {
font-size: 1.1em;
font-weight: bold;
color: #000;
background-color: #EEE;
width: 5em;
padding: 0.15em;
}
#control-panel button#go {
width: 3em;
}
#control-panel button:hover,
#control-panel button:focus {
color: #FFF;
background-color: #030;
}
#seek-field {
margin: 1em 0;
}
input#skipTo {
width: 3em;
font-size: 1.1em;
height: 1.5em;
}
#control-panel ul {
padding-left: 1.5em;
}
#control-panel li span {
font-weight: bold;
color: #C00;
}
#control-panel #error {
margin: 1em 0;
padding: 1em;
background-color: #FFC;
border: 1px solid #340449;
font-weight: bold;
display: none;
}
</style>
<!-- JavaScript for this example -->
<script>
$(document).ready(function() {
var player = new AblePlayer($('#video1'));
// handle button clicks by calling Able Player functions
$('button').on('click',function() {
var button = $(this).attr('id');
if (button === 'play') {
if (player.playing) {
player.pauseMedia();
$(this).text('Play');
} else {
player.playMedia();
$(this).text('Pause');
}
} else if (button === 'mute') {
if (player.isMuted()) {
player.setMute(false);
$(this).text('Mute');
} else {
player.setMute(true);
$(this).text('Unmute');
}
} else if (button === 'go') {
var seconds = $('#skipTo').val();
var duration = player.getDuration();
if (seconds >= 0 && seconds < duration) {
player.seekTo(seconds);
player.playMedia();
$('#play').text('Pause');
} else {
var error = "You can't play at ";
error += seconds + " seconds in a " + Math.round(duration);
error += " second video!";
$('#error').text(error).show().delay(5000).fadeOut(function() {
$(this).text('');
});
}
}
});
// Able Player is not required for listending for HTML5 media events
var $video = $('#video1');
$video.on('playing',function() {
$('#status-play').text('true');
});
$video.on('ended',function() {
$('#status-end').text('true');
});
})
</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 Home</a></li>
</ul>
</nav>
<main>
<h1>Controlling Able Player with external controls</h1>
<p>To control Able Player via external controls, assign a new AblePlayer instance to a variable
and omit the <code>data-able-player</code> attribute from the media element.
Then, all Able Player functions are exposed and can be accessed via your custom JavaScript.</p>
<div id="wrapper">
<video id="video1" preload="auto" poster="../media/wwa.jpg" playsinline>
<source type="video/mp4" src="../media/wwa.mp4" data-desc-src="../media/wwa_described.mp4"/>
<source type="video/webm" src="../media/wwa.webm" data-desc-src="../media/wwa_described.webm"/>
<track kind="captions" src="../media/wwa_captions_de.vtt" srclang="de" label="Deutsche"/>
<track kind="captions" src="../media/wwa_captions_en.vtt" srclang="en" label="English" default/>
<track kind="captions" src="../media/wwa_captions_es.vtt" srclang="es" label="Español"/>
<track kind="subtitles" src="../media/wwa_captions_fr.vtt" srclang="fr" label="Français"/>
<track kind="subtitles" src="../media/wwa_captions_ja.vtt" srclang="ja" lang="ja" label="日本語"/>
<track kind="descriptions" src="../media/wwa_description_de.vtt" srclang="de"/>
<track kind="descriptions" src="../media/wwa_description_en.vtt" srclang="en"/>
<track kind="descriptions" src="../media/wwa_description_es.vtt" srclang="es"/>
<track kind="descriptions" src="../media/wwa_description_fr.vtt" srclang="fr"/>
<track kind="descriptions" src="../media/wwa_description_ja.vtt" srclang="ja"/>
<track kind="chapters" src="../media/wwa_chapters_de.vtt" srclang="de"/>
<track kind="chapters" src="../media/wwa_chapters_en.vtt" srclang="en"/>
<track kind="chapters" src="../media/wwa_chapters_es.vtt" srclang="es"/>
<track kind="chapters" src="../media/wwa_chapters_fr.vtt" srclang="fr"/>
</video>
<div id="control-panel">
<h2>External Controls</h2>
<button id="play">Play</button>
<button id="mute">Mute</button>
<div id="seek-field">
<label for="skipTo">Play at (seconds):</label>
<input type="text" id="skipTo" name="skipTo"/>
<button id="go">Go</button>
</div>
<div id="error" role="alert"></div>
<h3>Playback Status</h3>
<ul>
<li>User played video: <span id="status-play">false</span></li>
<li>User played to end: <span id="status-end">false</span></li>
</ul>
</div>
</div>
</main>
</body>
</html>