Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

25
LINES

< > BotCompany Repo | #1028687 // hjs_playHum

JavaX fragment (include) [tags: use-pretranspiled]

Libraryless. Click here for Pure Java version (3098L/20K).

sS hjs_playHum() {
  ret hjs(replaceDollarVars([[
    var humSound = new Audio($url);
    var humSoundCanPlay = false, humSoundPlaying = false;
    humSound.loop = true;
    
    humSound.oncanplaythrough = function() {
      humSoundCanPlay = true;
    };
    
    // start playing and/or change volume
    function hum(volume) {
      humSound.volume = volume;
      if (humSoundPlaying) return;
      humSoundPlaying = true;
      humSound.play();
    }
    
    function stopHum() {
      if (!humSoundPlaying) return;
      humSoundPlaying = false;
      humSound.stop();
    }
  ]], url := jsQuote(dataSnippetLink(#1400406))));
}

download  show line numbers  debug dex  old transpilations   

Travelled to 7 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt, xrpafgyirdlv

No comments. add comment

Snippet ID: #1028687
Snippet name: hjs_playHum
Eternal ID of this version: #1028687/7
Text MD5: 45c7289aae719501e42a03c5802d7760
Transpilation MD5: a955088461f1f2340734b562cd683de5
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2020-07-05 21:09:26
Source code size: 659 bytes / 25 lines
Pitched / IR pitched: No / No
Views / Downloads: 141 / 225
Version history: 6 change(s)
Referenced in: [show references]