2011-03-03 3 views
0

soundManager2를 사용하여 onclick = "mySound.play()"라는 간단한 앵커를 만들었지 만 사운드가 실제로 들리기 전에 큰 간격 (거의 0.5 초)이 있습니다! 이것은 내가 미리 소리를 내었지만. 더 나은 응답 시간을 얻으려면 어떻게해야합니까?soundManager2로 어떻게 응답 시간을 연장 할 수 있습니까?

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en" > 
    <head> 
     <meta http-equiv="content-type" content="text/html; charset=utf-8" /> 
     <meta name="author" content="Shawn Inder" /> 
     <title>jeuReno</title> 
     <style type="text/css"> 
     <!-- 



     --> 
     </style> 

     <!-- include SM2 library --> 
     <script type="text/javascript" src="soundManager/script/soundmanager2.js"></script> 

     <!-- configure it for your use --> 
     <script type="text/javascript"> 

      soundManager.url = 'soundManager/swf/'; // directory where SM2 .SWFs live 

      // Note that SoundManager will determine and append the appropriate .SWF file to the URL, 
      // eg. /path/to/sm2-flash-movies/soundmanager2.swf automatically. 

      // Beta-ish HTML5 audio support (force-enabled for iPad), flash-free sound for Safari + Chrome. Enable if you want to try it! 
      // soundManager.useHTML5Audio = true; 

      // do this to skip flash block handling for now. See the flashblock demo when you want to start getting fancy. 
      soundManager.useFlashBlock = false; 

      // disable debug mode after development/testing.. 
      // soundManager.debugMode = false; 

      // Option 1: Simple onload() + createSound() method 

      /*soundManager.onload = function() { 
       // SM2 has loaded - now you can create and play sounds! 
       soundManager.createSound('helloWorld','sounds/crash.mp3'); 
       soundManager.play('helloWorld'); 
      };*/ 

      // Option 2 (better): More flexible onload() + createSound() method 

      /*soundManager.onload = function() { 

       var mySound = soundManager.createSound({ 
       id: 'aSound', 
       url: 'sounds/kick.mp3' 
       // onload: [ event handler function object ], 
       // other options here.. 
       }); 

       mySound.play(); 

      }*/ 

      // Option 3 (best): onready() + createSound()/ontimeout() methods for success/failure: 

      /*soundManager.onready(function() { 

       // SM2 has loaded - now you can create and play sounds! 
       var mySound = soundManager.createSound({ 
       id: 'aSound', 
       url: 'sounds/snare.mp3' 
       // onload: [ event handler function object ], 
       // other options here.. 
       }); 
       mySound.play(); 

      });*/ 

      soundManager.useHighPerformance = true; 

      soundManager.ontimeout(function() { 

       // (Optional) Hrmm, SM2 could not start. Show an error, etc.? 
       alert("wtf"); 

      }); 
     </script> 

     <script type="text/javascript"> 
      /*var snare = soundManager.createSound({ 
       id: 'snare', 
       url: 'sounds/snare.mp3' 
      }); 
      var kick = soundManager.createSound({ 
       id: 'kick', 
       url: 'sounds/kick.mp3' 
      }); 
      var crash = soundManager.createSound({ 
       id: 'crash', 
       url: 'sounds/crash.mp3' 
      }); 
      var highHat = soundManager.createSound({ 
       id: 'highHat', 
       url: 'sounds/highHat.mp3' 
      });*/ 
      soundManager.onready(function() { 

       // SM2 has loaded - now you can create and play sounds! 
       mySound = soundManager.createSound({ 
       id: 'aSound', 
       url: 'sounds/snare.mp3' 
       // onload: [ event handler function object ], 
       // other options here.. 
       }); 
       mySound.load(); 
       // mySound.play(); 

      }); 

     </script> 
    </head> 
    <body> 

     <a href="#" onclick="void(mySound.play());">click</a> 

    </body> 
</html> 

답변

1

곡이 미리로드됩니다 어디 볼 ​​수 없습니다 : 여기

는 소스 코드입니다. default 또는 createSound 섹션에서 autoLoad을 true로 설정하려면 (기본값은 createSound에 상속되어야합니다). 기본 섹션에서

이 될 것

또는 createSound 방법에 soundManager.autoLoad = true;autoLoad:true, id: 'aSound', url: 'sounds/kick.mp3'

관련 문제