Anchor controls inside bottom of video element

This commit is contained in:
Fernando Jiménez Moreno 2019-05-06 16:48:28 +02:00
parent 8a4d54af0b
commit 9496dff529
3 changed files with 27 additions and 17 deletions

View file

@ -1725,9 +1725,7 @@ impl HTMLMediaElement {
} }
fn render_controls(&self) { fn render_controls(&self) {
println!("render_controls");
// XXX cannot render controls while parsing. // XXX cannot render controls while parsing.
// XXX render controls as a top layer.
// XXX check that controls are not already rendered. // XXX check that controls are not already rendered.
let element = self.htmlelement.upcast::<Element>(); let element = self.htmlelement.upcast::<Element>();
if let Ok(shadow_root) = element.attach_shadow(IsUserAgentWidget::Yes) { if let Ok(shadow_root) = element.attach_shadow(IsUserAgentWidget::Yes) {

View file

@ -5,11 +5,17 @@ button {
border: none; border: none;
} }
.controls { .root {
display: block; display: block;
position: fixed; position: relative;
width: 100%; width: 100%;
padding: 0 9px; }
.controls {
position: absolute;
bottom: 0;
width: 100%;
height: 40px;
} }
.hidden { .hidden {

View file

@ -6,6 +6,7 @@
"use strict"; "use strict";
const MARKUP = ` const MARKUP = `
<div class="controls">
<button id="play-pause-button"></button> <button id="play-pause-button"></button>
<input id="progress" type="range" value="0" min="0" max="100" step="1"></input> <input id="progress" type="range" value="0" min="0" max="100" step="1"></input>
<span id="position-duration-box" class="hidden"> <span id="position-duration-box" class="hidden">
@ -14,6 +15,7 @@
</span> </span>
<button id="volume-switch"></button> <button id="volume-switch"></button>
<input id="volume-level" type="range" value="100" min="0" max="100" step="1"></input> <input id="volume-level" type="range" value="100" min="0" max="100" step="1"></input>
</div>
`; `;
// States. // States.
@ -84,10 +86,10 @@
this.media = this.controls.host; this.media = this.controls.host;
// Create root element and load markup. // Create root element and load markup.
const root = document.createElement("div"); this.root = document.createElement("div");
root.classList.add("controls"); this.root.classList.add("root");
root.innerHTML = MARKUP; this.root.innerHTML = MARKUP;
this.controls.appendChild(root); this.controls.appendChild(this.root);
// Import elements. // Import elements.
this.elements = {}; this.elements = {};
@ -210,6 +212,9 @@
} }
render(from = this.state) { render(from = this.state) {
// XXX This should use clientHeight.
this.root.style.height = this.media.videoHeight;
// Error // Error
if (this.state == ERRORED) { if (this.state == ERRORED) {
//XXX render errored state //XXX render errored state
@ -302,6 +307,7 @@
break; break;
case "volumechange": case "volumechange":
case "timeupdate": case "timeupdate":
case "resize":
this.render(); this.render();
break; break;
case "loadedmetadata": case "loadedmetadata":