Libraryless. Click here for Pure Java version (5138L/29K).
sclass WaveSurfer { S randomID = randomIDForPageElement(); S id = "wavesurfer-" + randomID; // id of container element S containerSelector; S varName = "waveSurfer_" + randomID; // name of variable for wavesurfer instance new MapSO options; S audioURL; S headStuff() { ret hscript("https://unpkg.com/wavesurfer.js"); } S container() { ret emptydiv(+id); } S js_init() { if (empty(containerSelector)) containerSelector = "#" + id; options.put(container := containerSelector); ret jsDollarVars([[ var $waveSurfer = WaveSurfer.create($options); ]], +options, waveSurfer := JS(varName)); } S js_loadAudio(S url) { ret jsDollarVars([[ $waveSurfer.load($url); ]], +url, waveSurfer := JS(varName)); } S completeHTML(S audioURL) { ret linesLL( headStuff(), container(), hjs(linesLL(js_init(), js_loadAudio(audioURL))) ); } S js_playPause() { ret jsDollarVars([[ $waveSurfer.playPause(); ]], waveSurfer := JS(varName)); } }
download show line numbers debug dex old transpilations
Travelled to 3 computer(s): bhatertpkbcr, mowyntqkapby, mqqgnosmbjvj
No comments. add comment
Snippet ID: | #1032543 |
Snippet name: | WaveSurfer - wavesurfer.js (graphical HTML audio player) as JavaX classs |
Eternal ID of this version: | #1032543/10 |
Text MD5: | 3f0c3ebd16d9036176d4e73fc0ace1de |
Transpilation MD5: | a800b8340dcf822fa09f6fb89c125eff |
Author: | stefan |
Category: | javax / html |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2021-09-22 15:36:59 |
Source code size: | 1101 bytes / 45 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 160 / 316 |
Version history: | 9 change(s) |
Referenced in: | [show references] |