1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-11-24 18:47:20 +00:00
TiddlyWiki5/js/macros/video.js
Jeremy Ruston 121907fd36 Added a video embed macro
Playing videos makes it easier to verify that a particular tiddler
hasn't been inadvertently refreshed (which would cause the video to
reload)
2012-02-01 12:36:40 +00:00

41 lines
1.3 KiB
JavaScript

/*\
title: js/macros/video.js
\*/
(function(){
/*jslint node: true */
"use strict";
var utils = require("../Utils.js");
exports.macro = {
name: "video",
types: ["text/html","text/plain"],
params: {
src: {byName: "default", type: "text", optional: false},
type: {byName: true, type: "text", optional: true},
width: {byName: true, type: "text", optional: true},
height: {byName: true, type: "text", optional: true}
},
render: function(type,tiddler,store,params) {
var videoType = params.type || "vimeo",
videoWidth = params.width || 640,
videoHeight = params.height || 360;
if(type === "text/html") {
switch(videoType) {
case "vimeo":
return "<iframe src='http://player.vimeo.com/video/" + params.src + "?autoplay=0' width='" + videoWidth + "' height='" + videoHeight + "' frameborder='0'></iframe>";
case "youtube":
return "<iframe type='text/html' width='" + videoWidth + "' height='" + videoHeight + "' src='http://www.youtube.com/embed/" + params.src + "' frameborder='0'></iframe>";
case "archiveorg":
return "<iframe src='http://www.archive.org/embed/" + params.src + "' width='" + videoWidth + "' height='" + videoHeight + "' frameborder='0'></iframe>";
}
} else if (type === "text/plain") {
return ""; // Not really sure how to render a video into plain text...
}
}
};
})();