Add feature to jump to marker (#471)

* Add options for setting marker and jumping to marker
* Correct "mute" to "muted"
This commit is contained in:
jacobcolbert
2019-05-06 00:41:16 -04:00
committed by Ilya Grigorik
parent e91b4c9cdb
commit d8965f644c
3 changed files with 30 additions and 9 deletions

View File

@@ -486,6 +486,10 @@
pauseSpeed(v, value);
} else if (action === 'muted') {
muted(v, value);
} else if (action === 'mark') {
setMark(v);
} else if (action === 'jump') {
jumpToMark(v);
}
}
});
@@ -520,6 +524,16 @@
v.muted = v.muted !== true;
}
function setMark(v) {
v.vsc.mark = v.currentTime;
}
function jumpToMark(v) {
if (v.vsc.mark && typeof v.vsc.mark === "number") {
v.currentTime = v.vsc.mark;
}
}
function handleDrag(video, controller, e) {
const shadowController = controller.shadowRoot.querySelector('#controller');

View File

@@ -101,3 +101,8 @@ select {
.customForce {
display: none;
}
.customKey {
color: transparent;
text-shadow: 0 0 0 #000000;
}

View File

@@ -102,6 +102,9 @@ function updateCustomShortcutInputText(inputItem, keyCode) {
inputItem.keyCode = keyCode;
}
// List of custom actions for which customValue should be disabled
var customActionsNoValues=["pause","muted","mark","jump"];
function add_shortcut() {
var html = `<select class="customDo">
<option value="slower">Decrease speed</option>
@@ -112,6 +115,8 @@ function add_shortcut() {
<option value="fast">Preferred speed</option>
<option value="muted">Mute</option>
<option value="pause">Pause</option>
<option value="mark">Set marker</option>
<option value="jump">Jump to marker</option>
</select>
<input class="customKey" type="text" placeholder="press a key"/>
<input class="customValue" type="text" placeholder="value (0.10)"/>
@@ -192,7 +197,7 @@ function restore_options() {
const dom = document.querySelector(".customs:last-of-type")
dom.querySelector(".customDo").value = item["action"];
if (item["action"] === "pause" || item["action"] === "muted")
if (customActionsNoValues.includes(item["action"]))
dom.querySelector(".customValue").disabled = true;
updateCustomShortcutInputText(dom.querySelector(".customKey"), item["key"]);
@@ -262,13 +267,10 @@ document.addEventListener('DOMContentLoaded', function () {
});
document.addEventListener('change', (event) => {
eventCaller(event, "customDo", function () {
switch (event.target.value) {
case "muted":
case "pause":
if (customActionsNoValues.includes(event.target.value)) {
event.target.nextElementSibling.nextElementSibling.disabled = true;
event.target.nextElementSibling.nextElementSibling.value = 0;
break;
default:
} else {
event.target.nextElementSibling.nextElementSibling.disabled = false;
}
})