<video controls src="video.mp4"></video>DataCue: value property / notebook
DataCue: value property
Runnable notebook: every JavaScript, HTML and CSS example on this page executes in a sandboxed local frame. Nothing leaves the browser.
const video = document.querySelector("video");
const track = video.addTextTrack("metadata", "Geo Track");
track.mode = "hidden";
const cue = new DataCue(
0,
10,
{ latitude: 51.5043, longitude: -0.0762 },
"org.example.geo",
);
track.addCue(cue);
console.log(cue.value);
// { latitude: 51.5043, longitude: -0.0762 }<video controls src="video.mp4"></video>const video = document.querySelector("video");
const track = video.addTextTrack("metadata", "Events");
track.mode = "hidden";
const cue1 = new DataCue(5, 10, { action: "showBanner", text: "Welcome!" });
const cue2 = new DataCue(15, 20, { action: "highlight", playerId: 7 });
cue1.addEventListener("enter", (e) => {
console.log(e.target.value.action);
// "showBanner"
});
cue2.addEventListener("enter", (e) => {
console.log(e.target.value.action);
// "highlight"
});
track.addCue(cue1);
track.addCue(cue2);const cue = new DataCue(0, 5, "initial data");
cue.value = { updated: true, score: 42 };
console.log(cue.value);
// { updated: true, score: 42 }