1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-07-08 21:14:25 +00:00
TiddlyWiki5/core/modules/parsers/videoparser.js
donmor 588af44d4c Scale embedded videos and audios to fit their container (#3943)
* Update videoparser.js

* Update audioparser.js

* Update videoparser.js

* Update audioparser.js
2019-10-19 11:44:18 +01:00

38 lines
855 B
JavaScript

/*\
title: $:/core/modules/parsers/videoparser.js
type: application/javascript
module-type: parser
The video parser parses a video tiddler into an embeddable HTML element
\*/
(function(){
/*jslint node: true, browser: true */
/*global $tw: false */
"use strict";
var VideoParser = function(type,text,options) {
var element = {
type: "element",
tag: "video",
attributes: {
controls: {type: "string", value: "controls"},
style: {type: "string", value: "width: 100%; object-fit: contain"}
}
},
src;
if(options._canonical_uri) {
element.attributes.src = {type: "string", value: options._canonical_uri};
} else if(text) {
element.attributes.src = {type: "string", value: "data:" + type + ";base64," + text};
}
this.tree = [element];
};
exports["video/mp4"] = VideoParser;
exports["video/quicktime"] = VideoParser;
})();