mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2025-11-01 16:13:00 +00:00
Add audio parser for handling audio content
This commit is contained in:
37
core/modules/parsers/audioparser.js
Normal file
37
core/modules/parsers/audioparser.js
Normal file
@@ -0,0 +1,37 @@
|
||||
/*\
|
||||
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: {
|
||||
controls: {type: "string", value: "controls"}
|
||||
}
|
||||
},
|
||||
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["audio/mpeg"] = AudioParser;
|
||||
exports["audio/mp3"] = AudioParser;
|
||||
exports["audio/mp4"] = AudioParser;
|
||||
|
||||
})();
|
||||
|
||||
Reference in New Issue
Block a user