2023-04-04 22:56:34 +00:00
|
|
|
<html>
|
|
|
|
<head>
|
|
|
|
<style type="text/css">
|
|
|
|
video {
|
|
|
|
border: 1px solid #333;
|
|
|
|
}
|
|
|
|
|
|
|
|
table, td {
|
|
|
|
border: 1px solid #333;
|
|
|
|
border-collapse: collapse;
|
|
|
|
}
|
|
|
|
|
|
|
|
thead, tfoot {
|
|
|
|
background-color: #333333;
|
|
|
|
color: #ffffff;
|
|
|
|
}
|
2023-04-08 13:18:09 +00:00
|
|
|
|
|
|
|
.horizontal > * {
|
|
|
|
display: inline-block;
|
|
|
|
}
|
2023-04-04 22:56:34 +00:00
|
|
|
</style>
|
|
|
|
</head>
|
|
|
|
<body>
|
2023-04-08 13:18:09 +00:00
|
|
|
<div class=horizontal>
|
|
|
|
<table>
|
|
|
|
<thead>
|
|
|
|
<tr>
|
|
|
|
<th colspan="2">Metadata</th>
|
|
|
|
</tr>
|
|
|
|
</thead>
|
|
|
|
<tbody>
|
|
|
|
<tr>
|
|
|
|
<td>ID</td>
|
|
|
|
<td id=id>null</td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td>Is Selected</td>
|
|
|
|
<td id=selected>false</td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td>Width</td>
|
|
|
|
<td id=width>0px</td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td>Height</td>
|
|
|
|
<td id=height>0px</td>
|
|
|
|
</tr>
|
|
|
|
</tbody>
|
|
|
|
</table>
|
|
|
|
|
|
|
|
<table>
|
|
|
|
<thead>
|
|
|
|
<tr>
|
|
|
|
<th colspan="2">Playback State</th>
|
|
|
|
</tr>
|
|
|
|
</thead>
|
|
|
|
<tbody>
|
2023-04-10 14:14:32 +00:00
|
|
|
<tr>
|
|
|
|
<td>Current Time</td>
|
|
|
|
<td id=time>0.00 seconds</td>
|
|
|
|
</tr>
|
2023-04-08 13:18:09 +00:00
|
|
|
<tr>
|
|
|
|
<td>Duration</td>
|
2023-04-10 14:14:32 +00:00
|
|
|
<td id=duration>0.00 seconds</td>
|
2023-04-08 13:18:09 +00:00
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td>Play State</td>
|
|
|
|
<td id=state>paused</td>
|
|
|
|
</tr>
|
2023-04-11 00:05:19 +00:00
|
|
|
<tr>
|
|
|
|
<td>Ended</td>
|
|
|
|
<td id=ended>false</td>
|
|
|
|
</tr>
|
2023-04-08 13:18:09 +00:00
|
|
|
</tbody>
|
|
|
|
</table>
|
2023-04-20 12:41:39 +00:00
|
|
|
|
|
|
|
<fieldset>
|
|
|
|
<legend>Select a video playback option:</legend>
|
|
|
|
<div>
|
|
|
|
<input type=radio id=option-default value=default name=options>
|
|
|
|
<label for=option-default>Default</label>
|
|
|
|
</div>
|
|
|
|
<div>
|
|
|
|
<input type=radio id=option-autoplay value=autoplay name=options>
|
|
|
|
<label for=option-autoplay>Autoplay</label>
|
|
|
|
</div>
|
|
|
|
<div>
|
|
|
|
<input type=radio id=option-poster value=poster name=options>
|
|
|
|
<label for=option-poster>Poster</label>
|
|
|
|
</div>
|
|
|
|
</fieldset>
|
2023-04-08 13:18:09 +00:00
|
|
|
</div>
|
2023-04-04 22:56:34 +00:00
|
|
|
|
|
|
|
<br />
|
|
|
|
|
2024-06-24 10:45:42 +00:00
|
|
|
<video id=video controls src="test-webm.webm"></video>
|
2023-04-04 22:56:34 +00:00
|
|
|
|
|
|
|
<script type="text/javascript">
|
|
|
|
let video = document.getElementById('video');
|
|
|
|
|
2023-04-20 12:41:39 +00:00
|
|
|
const params = new URLSearchParams(document.location.search);
|
|
|
|
const option = params.get('option');
|
|
|
|
|
|
|
|
if (option === 'autoplay') {
|
|
|
|
document.getElementById('option-autoplay').setAttribute('checked', '');
|
|
|
|
video.setAttribute('autoplay', '');
|
|
|
|
} else if (option === 'poster') {
|
|
|
|
document.getElementById('option-poster').setAttribute('checked', '');
|
|
|
|
video.setAttribute('poster', '../../wallpapers/grid.png');
|
|
|
|
} else {
|
|
|
|
document.getElementById('option-default').setAttribute('checked', '');
|
|
|
|
}
|
|
|
|
|
2023-04-04 22:56:34 +00:00
|
|
|
video.videoTracks.onaddtrack = (event) => {
|
|
|
|
document.getElementById('id').textContent = event.track.id;
|
|
|
|
document.getElementById('selected').textContent = event.track.selected;
|
|
|
|
};
|
|
|
|
|
2023-04-10 14:14:32 +00:00
|
|
|
video.addEventListener('timeupdate', () => {
|
|
|
|
document.getElementById('time').textContent = `${video.currentTime.toFixed(2)} seconds`;
|
|
|
|
});
|
|
|
|
|
2023-04-04 22:56:34 +00:00
|
|
|
video.addEventListener('durationchange', () => {
|
2023-04-10 14:14:32 +00:00
|
|
|
document.getElementById('duration').textContent = `${video.duration.toFixed(2)} seconds`;
|
2023-04-04 22:56:34 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
video.addEventListener('loadedmetadata', () => {
|
|
|
|
document.getElementById('width').textContent = `${video.videoWidth}px`;
|
|
|
|
document.getElementById('height').textContent = `${video.videoHeight}px`;
|
|
|
|
});
|
2023-04-08 13:18:09 +00:00
|
|
|
|
|
|
|
video.addEventListener('playing', () => {
|
|
|
|
document.getElementById('state').textContent = 'playing';
|
2023-04-11 00:05:19 +00:00
|
|
|
document.getElementById('ended').textContent = video.ended;
|
2023-04-08 13:18:09 +00:00
|
|
|
});
|
|
|
|
video.addEventListener('waiting', () => {
|
|
|
|
document.getElementById('state').textContent = 'waiting';
|
2023-04-11 00:05:19 +00:00
|
|
|
document.getElementById('ended').textContent = video.ended;
|
2023-04-08 13:18:09 +00:00
|
|
|
});
|
|
|
|
video.addEventListener('pause', () => {
|
|
|
|
document.getElementById('state').textContent = 'paused';
|
2023-04-11 00:05:19 +00:00
|
|
|
document.getElementById('ended').textContent = video.ended;
|
2023-04-08 13:18:09 +00:00
|
|
|
});
|
2023-04-20 12:41:39 +00:00
|
|
|
|
|
|
|
for (const option of document.getElementsByName('options')) {
|
|
|
|
option.addEventListener('change', function() {
|
|
|
|
if (!this.checked) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
const location = `${window.location.pathname}?option=${this.value}`;
|
|
|
|
window.location.href = location;
|
|
|
|
});
|
|
|
|
}
|
2023-04-04 22:56:34 +00:00
|
|
|
</script>
|
|
|
|
</body>
|
|
|
|
</html>
|