AudioLoader.html 3.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8">
  5. <title>AudioLoader - Three.js Docs</title>
  6. <meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
  7. <script src="../scripts/highlight.min.js"></script>
  8. <link type="text/css" rel="stylesheet" href="../styles/highlight-three.css">
  9. <link type="text/css" rel="stylesheet" href="../styles/page.css">
  10. </head>
  11. <body>
  12. <p class="inheritance" translate="no"><a href="Loader.html">Loader</a> → </p>
  13. <h1 translate="no">AudioLoader</h1>
  14. <section>
  15. <header>
  16. <div class="class-description"><p>Class for loading audio buffers. Audios are internally
  17. loaded via <a href="FileLoader.html">FileLoader</a>.</p></div>
  18. <h2>Code Example</h2>
  19. <div translate="no"><pre><code class="language-js">const audioListener = new THREE.AudioListener();
  20. const ambientSound = new THREE.Audio( audioListener );
  21. const loader = new THREE.AudioLoader();
  22. const audioBuffer = await loader.loadAsync( 'audio/ambient_ocean.ogg' );
  23. ambientSound.setBuffer( audioBuffer );
  24. ambientSound.play();
  25. </code></pre></div>
  26. </header>
  27. <article>
  28. <div class="container-overview">
  29. <h2>Constructor</h2>
  30. <h3 class="name name-method" id="AudioLoader" translate="no">new <a href="#AudioLoader">AudioLoader</a><span class="signature">( manager : <span class="param-type">LoadingManager</span> )</span> </h3>
  31. <div class="method">
  32. <div class="description">
  33. <p>Constructs a new audio loader.</p>
  34. </div>
  35. <table class="params">
  36. <tbody>
  37. <tr>
  38. <td class="name"><code>manager</code></td>
  39. <td class="description last"><p>The loading manager.</p></td>
  40. </tr>
  41. </tbody>
  42. </table>
  43. </div>
  44. </div>
  45. <h2 class="subsection-title">Methods</h2>
  46. <h3 class="name name-method" id="load" translate="no">.<a href="#load">load</a><span class="signature">( url : <span class="param-type">string</span>, onLoad : <span class="param-type">function</span>, onProgress : <span class="param-type">onProgressCallback</span>, onError : <span class="param-type">onErrorCallback</span> )</span> </h3>
  47. <div class="method">
  48. <div class="description">
  49. <p>Starts loading from the given URL and passes the loaded audio buffer
  50. to the <code>onLoad()</code> callback.</p>
  51. </div>
  52. <table class="params">
  53. <tbody>
  54. <tr>
  55. <td class="name"><code>url</code></td>
  56. <td class="description last"><p>The path/URL of the file to be loaded. This can also be a data URI.</p></td>
  57. </tr>
  58. <tr>
  59. <td class="name"><code>onLoad</code></td>
  60. <td class="description last"><p>Executed when the loading process has been finished.</p></td>
  61. </tr>
  62. <tr>
  63. <td class="name"><code>onProgress</code></td>
  64. <td class="description last"><p>Executed while the loading is in progress.</p></td>
  65. </tr>
  66. <tr>
  67. <td class="name"><code>onError</code></td>
  68. <td class="description last"><p>Executed when errors occur.</p></td>
  69. </tr>
  70. </tbody>
  71. </table>
  72. <dl class="details">
  73. <dt class="tag-overrides"><strong>Overrides:</strong> <a href="Loader.html#load">Loader#load</a></dt>
  74. </dl>
  75. </div>
  76. <h2 class="subsection-title">Source</h2>
  77. <p>
  78. <a href="https://github.com/mrdoob/three.js/blob/master/src/loaders/AudioLoader.js" target="_blank" rel="noopener" translate="no">src/loaders/AudioLoader.js</a>
  79. </p>
  80. </article>
  81. </section>
  82. <script src="../scripts/linenumber.js"></script>
  83. <script src="../scripts/page.js"></script>
  84. </body>
  85. </html>
粤ICP备19079148号