mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-12-28 02:50:27 +00:00
Add audio parser for handling audio content
This commit is contained in:
parent
ea3bdb5556
commit
2ffe53f191
@ -1759,6 +1759,8 @@ $tw.boot.startup = function(options) {
|
||||
$tw.utils.registerFileType("image/svg+xml","utf8",".svg",{flags:["image"]});
|
||||
$tw.utils.registerFileType("image/x-icon","base64",".ico",{flags:["image"]});
|
||||
$tw.utils.registerFileType("application/font-woff","base64",".woff");
|
||||
$tw.utils.registerFileType("audio/mp3","base64",".mp3");
|
||||
$tw.utils.registerFileType("audio/mp4","base64",[".mp4",".m4a"]);
|
||||
$tw.utils.registerFileType("text/x-markdown","utf8",[".md",".markdown"]);
|
||||
// Create the wiki store for the app
|
||||
$tw.wiki = new $tw.Wiki();
|
||||
|
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;
|
||||
|
||||
})();
|
||||
|
@ -0,0 +1,3 @@
|
||||
title: Caruso - Ave Maria
|
||||
type: audio/mp3
|
||||
_canonical_uri: https://archive.org/download/Caruso_part1/Caruso-AveMaria.mp3
|
BIN
editions/tw5.com/tiddlers/demonstrations/TiddlyWiki.mp3
Normal file
BIN
editions/tw5.com/tiddlers/demonstrations/TiddlyWiki.mp3
Normal file
Binary file not shown.
@ -0,0 +1,2 @@
|
||||
title: TiddlyWiki.mp3
|
||||
type: audio/mp3
|
25
editions/tw5.com/tiddlers/workingwithtw/Audio.tid
Normal file
25
editions/tw5.com/tiddlers/workingwithtw/Audio.tid
Normal file
@ -0,0 +1,25 @@
|
||||
created: 20141018131647392
|
||||
modified: 20141018132325901
|
||||
tags: [[Working with TiddlyWiki]]
|
||||
title: Audio
|
||||
type: text/vnd.tiddlywiki
|
||||
|
||||
Audio files can be incorporated into TiddlyWiki in a very similar way to [[images|Images]].
|
||||
|
||||
! Embedded Audio
|
||||
|
||||
Small audio files can be embedded directly within TiddlyWiki. Embedding isn't suitable for large files (over a few hundred kilobytes) because it increases the size of the TiddlyWiki file.
|
||||
|
||||
For example, the tiddler [[TiddlyWiki.mp3]] contains an MP3 recording of the word "TiddlyWiki". Viewing the tiddler directly should show an audio player that allows playback.
|
||||
|
||||
You can also transclude audio files. For example:
|
||||
|
||||
<<wikitext-example-without-html '{{TiddlyWiki.mp3}}'>>
|
||||
|
||||
! External Audio
|
||||
|
||||
External audio tiddlers use the ''_canonical_uri'' field to point to an external audio file, and have a block ''text'' field. This reduces their size considerably, and still allows for playback.
|
||||
|
||||
For example, the tiddler [[Caruso - Ave Maria]] points to an online audio recording hosted on http://archive.org:
|
||||
|
||||
<<wikitext-example-without-html '{{Caruso - Ave Maria}}'>>
|
Loading…
Reference in New Issue
Block a user