From 2ffe53f1916e4b746cc6d7e74e8f4ac75c72e38a Mon Sep 17 00:00:00 2001 From: Jermolene Date: Sat, 18 Oct 2014 14:50:07 +0100 Subject: [PATCH] Add audio parser for handling audio content --- boot/boot.js | 2 + core/modules/parsers/audioparser.js | 37 ++++++++++++++++++ .../demonstrations/Caruso - Ave Maria.tid | 3 ++ .../tiddlers/demonstrations/TiddlyWiki.mp3 | Bin 0 -> 8320 bytes .../demonstrations/TiddlyWiki.mp3.meta | 2 + .../tw5.com/tiddlers/workingwithtw/Audio.tid | 25 ++++++++++++ 6 files changed, 69 insertions(+) create mode 100644 core/modules/parsers/audioparser.js create mode 100644 editions/tw5.com/tiddlers/demonstrations/Caruso - Ave Maria.tid create mode 100644 editions/tw5.com/tiddlers/demonstrations/TiddlyWiki.mp3 create mode 100644 editions/tw5.com/tiddlers/demonstrations/TiddlyWiki.mp3.meta create mode 100644 editions/tw5.com/tiddlers/workingwithtw/Audio.tid diff --git a/boot/boot.js b/boot/boot.js index 0748f5c86..a58da93e1 100644 --- a/boot/boot.js +++ b/boot/boot.js @@ -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(); diff --git a/core/modules/parsers/audioparser.js b/core/modules/parsers/audioparser.js new file mode 100644 index 000000000..8d37e4ec6 --- /dev/null +++ b/core/modules/parsers/audioparser.js @@ -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; + +})(); + diff --git a/editions/tw5.com/tiddlers/demonstrations/Caruso - Ave Maria.tid b/editions/tw5.com/tiddlers/demonstrations/Caruso - Ave Maria.tid new file mode 100644 index 000000000..ee43d47e6 --- /dev/null +++ b/editions/tw5.com/tiddlers/demonstrations/Caruso - Ave Maria.tid @@ -0,0 +1,3 @@ +title: Caruso - Ave Maria +type: audio/mp3 +_canonical_uri: https://archive.org/download/Caruso_part1/Caruso-AveMaria.mp3 diff --git a/editions/tw5.com/tiddlers/demonstrations/TiddlyWiki.mp3 b/editions/tw5.com/tiddlers/demonstrations/TiddlyWiki.mp3 new file mode 100644 index 0000000000000000000000000000000000000000..3c5125711f55886357bd4435a563aa863b843ab1 GIT binary patch literal 8320 zcmeHs2T)Vrx9$l92ps~_#Sn^sfT4(Wv=}n{w zC@LaVL@A22oOgnH-<>z}=FYwIe{*Nv+%+dB`y@GMul4O!zP+NOE=>+V0{1gl(N~2A zFz98jW@PwxsADemcWA63`FCilruTPfqhb1I2)+G}{0{>E2?W6X6qo<#=hm0K+@Rku zLa*b{5eBfavGMcsi$WqJBXb@SEiElmNUW``FG1q!>gwa;6ADRUVqz8~g@uJxkTf(j zv_R6<*4EwKJp{?b#Kb#DmX?;jL9(^AwFAk)!2t+@&|JLwDh3+T5@*l)!0(V$6vG05 zEJ}a^W&pq*k@WDAUU4FQ@&C1e`!&B8C?pa95CA}rA^xx*Ta?GcaLw5`tLdY`0!Zz z$@fo9ZcMc~Oz&1QFIIdm_QFLdzz>2u9!n3sY`@T_qbT9J7R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~L;FZBz(M?}O}&>MCrJ^Sa6YC;l-`Uh z_Q#tWR2|*>!7mlLFf8WLEmWG;->H8s9gEc%&wM5BHp z+bdY99GiS~Oug?hu*vX7$FJoU#rmY#rV&eIAE!RqX0sP$F{-H3o|-W_^KJ5?5yTy= zz(e~#+ir21H@mTtkmvqxLiO%gtR)!W|JVZ>WPCX2?Bi2&j}COh#rSz{c>_!UfL0r# z^$tQbsF%un;hBmQXo~F0vby$XOl)zRgopG~6qrl~V+lRg8Cmu|Gbg*LOu>QT)rjp+ zg1e*ELD>m$Y7wuI8%b@1{i=>kC}0n#`}jVYId<_t^$%)m)`?OXRJC06tee3?&;an* z)9H)0*@Pv*j*F)4{nF<&?%EGBbFsRfq^h&d;-=jA<-y0&LoGnEXAe&fC{NsSBtZ8a z^~~vkM5}-2RdaH@6kC01B`Gf$Om{_t45ARv-HZ7#OU>mHSFwoNNhm3j$MM)GMGVh3_cwgt!jLYqV zM>vfJ?9APM#wy*BkZ=Ma5?5kg`u)MJ%6sBEHsXyGo&Zck9}!0AL*VVQ`(RN>Ezw6> zH#DxFFdyda=1|qkw5KAAX5BTe)#sk0BWV?mO4H3OV19M04Ftdb{nJN6*5bb)|Hs`VN7x6* zT`bJJ{x@(`1S^AQslS241MvUCEdOn{kP`L*Y{Q(x>@uHJ&7VM}==3*ORC4J36R7`h zl>_&gT!^6?amQb;@Nq-M{wP&YpaRuO5)7bBC9-rxWL literal 0 HcmV?d00001 diff --git a/editions/tw5.com/tiddlers/demonstrations/TiddlyWiki.mp3.meta b/editions/tw5.com/tiddlers/demonstrations/TiddlyWiki.mp3.meta new file mode 100644 index 000000000..8a1a6ca21 --- /dev/null +++ b/editions/tw5.com/tiddlers/demonstrations/TiddlyWiki.mp3.meta @@ -0,0 +1,2 @@ +title: TiddlyWiki.mp3 +type: audio/mp3 diff --git a/editions/tw5.com/tiddlers/workingwithtw/Audio.tid b/editions/tw5.com/tiddlers/workingwithtw/Audio.tid new file mode 100644 index 000000000..3b0bee583 --- /dev/null +++ b/editions/tw5.com/tiddlers/workingwithtw/Audio.tid @@ -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: + +<> + +! 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: + +<>