How do you download audio files after the full download of the page?



  • How to download audio files after full download of the website page (i mean when the entire website is downloaded cssjsphotos and so on, and the last thing to download audio files?

    $(function(){  
    
      $('<audio id="chatAudio"><source src="audio/notify.ogg" type="audio/ogg"><source src="audio/notify.mp3" type="audio/mpeg"><source src="audio/notify.wav" type="audio/wav"></audio>').appendTo('body');
    
        if(22==22){
          $('#chatAudio')[0].play();
        }
    
    });
    



  • If you use a flame http://ionden.com/a/plugins/ion.sound/index.html There's no such problem. You can tell in the configuration if you need to pre-load sound.

    For example:

    ion.sound({
        sounds: [
            {name: "notify"}
        ],
        path: "static/sounds/",
        preload: false
    });
    

    // а потом в любой нужный момент просто вызвать
    // звук загрузится только тогда, когда будет нужен

    ion.sound.play("notify");

    If you want to work through your code, it's a good decision to put sound down in the body.onload. This event will be caused only after all other resources are downloaded (including external enumerators, analyst files and others). It can be done:

    $(document.body).on('load', function () {
    // здесь
    });




Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2