サウンド実装用コピペ

0

    var loadedSounds=0;
    var assetPath = "./sounds/";
    var sounds = [
    {src:"click.mp3",id:"click"},

    {src:"bgm.mp3",id:"bgm"}
    ];

    var bgm;

    $(function(){
    //createjs.Sound.alternateExtensions = ["mp3"];//任意?
    createjs.Sound.on("fileload", handleLoad);
    createjs.Sound.registerSounds(sounds, assetPath);
    });

    function handleLoad(evt){
    loadedSounds++;
    if(loadedSounds>=sounds.length){
    console.log("complete");
    }
    }

    function playSE(str){
    createjs.Sound.play(str);
    }

    function playBGM(){
    bgm=createjs.Sound.play("bgm",{loop:-1});

    bgm.volume=0.2;
    }

     

    function pauseBGM(bol){

    bgm.setPaused(bol);

    }

    function seekBGM(num){

    bgm.setPosition(num);

    }



    selected entries

    categories

    archives

    recent comment

    recommend

    profile

    BOOKS

    links

    search this site.

    others