2014-10-18 13:50:07 +00:00
|
|
|
/*\
|
|
|
|
title: $:/core/modules/parsers/audioparser.js
|
|
|
|
type: application/javascript
|
|
|
|
module-type: parser
|
|
|
|
|
|
|
|
The audio parser parses an audio tiddler into an embeddable HTML element
|
|
|
|
|
|
|
|
\*/
|
|
|
|
(function(){
|
|
|
|
|
|
|
|
/*jslint node: true, browser: true */
|
|
|
|
/*global $tw: false */
|
|
|
|
"use strict";
|
|
|
|
|
|
|
|
var AudioParser = function(type,text,options) {
|
|
|
|
var element = {
|
|
|
|
type: "element",
|
|
|
|
tag: "audio",
|
|
|
|
attributes: {
|
2019-10-19 10:44:18 +00:00
|
|
|
controls: {type: "string", value: "controls"},
|
|
|
|
style: {type: "string", value: "width: 100%; object-fit: contain"}
|
2014-10-18 13:50:07 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
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];
|
2022-05-08 19:48:33 +00:00
|
|
|
this.source = text;
|
|
|
|
this.type = type;
|
2014-10-18 13:50:07 +00:00
|
|
|
};
|
|
|
|
|
2014-10-19 20:09:17 +00:00
|
|
|
exports["audio/ogg"] = AudioParser;
|
2014-10-18 13:50:07 +00:00
|
|
|
exports["audio/mpeg"] = AudioParser;
|
|
|
|
exports["audio/mp3"] = AudioParser;
|
|
|
|
exports["audio/mp4"] = AudioParser;
|
|
|
|
|
|
|
|
})();
|
|
|
|
|