Skip to content

Instantly share code, notes, and snippets.

@digitarald
Created February 19, 2013 16:54
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save digitarald/4987688 to your computer and use it in GitHub Desktop.
Save digitarald/4987688 to your computer and use it in GitHub Desktop.
if ('MozActivity' in window) { // feature detection
// When getting elements, like document.getElementsByClassName('video-links')
// rather use event delegation, like
// `jQuery(document).on('click', 'video', fn)
document.getElementById('video-1').onclick = function(evt) {
evt.preventDefault(); // Prevent click behaviour
console.log("Launching Video!");
var activity = new MozActivity({
name: "view",
data: {
type: "video/mp4",
url: 'http://www.archive.org/download/Mario1_507/Mario1_507_512kb.mp4'
}
});
// Optional events (you can fire and forget)
activity.onsuccess = function() {
console.log("Video finished playing, want to react?");
};
activity.onerror = function() {
console.log("Video wasn't played, want to react?");
};
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment