Skip to content

Instantly share code, notes, and snippets.

@cgiffard
Created June 29, 2011 03:51
Show Gist options
  • Save cgiffard/1053047 to your computer and use it in GitHub Desktop.
Save cgiffard/1053047 to your computer and use it in GitHub Desktop.
WebVTT Metadata JS API Idea
WEBVTT
Language=zh
Kind=Caption
Version=V1_ABC
License=CC-BY-SA
Description=An example file demonstrating JS access for WebVTT metadata
COMMENT -->
This file was patched together from WebVTT examples here: http://blog.gingertech.net/2011/06/27/recent-developments-around-webvtt/
1
00:00:15.000 --> 00:00:17.950
first cue
// Proposal 1 - key/value in the form of a raw object
// Property names are camel cased - "My Property Name" becomes "myPropertyName" ala CSS
// Get description of example track
document.getElementsByTagName("video")[0].tracks[0].metadata.description;
document.getElementsByTagName("video")[0].tracks[0].metadata["description"];
// Mutation would be simple
document.getElementsByTagName("video")[0].tracks[0].metadata["description"] = "Here's a new description assigned by JS!";
// Proposal 2 (more verbose, in line with DOM. Don't like this one anywhere near as much.)
var myVideo = document.getElementsByTagName("video")[0];
// Get licence of example track
myVideo.tracks[0].metadata.getMetadataItem("licence");
// This would also allow mutation
myVideo.tracks[0].metadata.setMetadataItem("licence","GPLv3");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment