index.html 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
  5. <title>wavesurfer.js | Annotation tool</title>
  6. <link href="data:image/gif;" rel="icon" type="image/x-icon" />
  7. <!-- Bootstrap -->
  8. <link href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet">
  9. <link rel="stylesheet" href="../css/style.css" />
  10. <link rel="stylesheet" href="../css/ribbon.css" />
  11. <link rel="stylesheet" href="app.css" />
  12. <link rel="screenshot" itemprop="screenshot" href="https://katspaugh.github.io/wavesurfer.js/example/screenshot.png" />
  13. <!-- wavesurfer.js -->
  14. <script src="../../dist/wavesurfer.js"></script>
  15. <!-- plugins -->
  16. <script src="../../dist/plugin/wavesurfer.timeline.js"></script>
  17. <script src="../../dist/plugin/wavesurfer.regions.js"></script>
  18. <script src="../../dist/plugin/wavesurfer.minimap.js"></script>
  19. <!-- App -->
  20. <script src="../trivia.js"></script>
  21. <script src="app.js"></script>
  22. </head>
  23. <body itemscope itemtype="http://schema.org/WebApplication">
  24. <div class="container">
  25. <div class="header">
  26. <ul class="nav nav-pills pull-right">
  27. <li><a href="/"><i class="glyphicon glyphicon-home"></i></a></li>
  28. </ul>
  29. <h1 itemprop="name">wavesurfer.js Annotations Tool</h1>
  30. </div>
  31. <div id="demo">
  32. <p id="subtitle" class="text-center text-info">&nbsp;</p>
  33. <div id="wave-timeline"></div>
  34. <div id="waveform">
  35. <!-- Here be waveform -->
  36. </div>
  37. <div class="row" style="margin: 30px 0">
  38. <div class="col-sm-8">
  39. <p>
  40. Click on a region to enter an annotation.<br />
  41. Shift-click plays a region in a loop.
  42. </p>
  43. </div>
  44. <div class="col-sm-2">
  45. <button class="btn btn-primary btn-block" data-action="play">
  46. <span id="play">
  47. <i class="glyphicon glyphicon-play"></i>
  48. Play
  49. </span>
  50. <span id="pause" style="display: none">
  51. <i class="glyphicon glyphicon-pause"></i>
  52. Pause
  53. </span>
  54. </button>
  55. </div>
  56. <div class="col-sm-2">
  57. <button class="btn btn-info btn-block" data-action="export" title="Export annotations to JSON">
  58. <i class="glyphicon glyphicon-file"></i>
  59. Export
  60. </button>
  61. </div>
  62. </div>
  63. </div>
  64. <form role="form" name="edit" style="opacity: 0; transition: opacity 300ms linear; margin: 30px 0;">
  65. <div class="form-group">
  66. <label for="start">Start</label>
  67. <input class="form-control" id="start" name="start" />
  68. </div>
  69. <div class="form-group">
  70. <label for="end">End</label>
  71. <input class="form-control" id="end" name="end" />
  72. </div>
  73. <div class="form-group">
  74. <label for="note">Note</label>
  75. <textarea id="note" class="form-control" rows="3" name="note"></textarea>
  76. </div>
  77. <button type="submit" class="btn btn-success btn-block">Save</button>
  78. <center><i>or</i></center>
  79. <button type="button" class="btn btn-danger btn-block" data-action="delete-region">Delete</button>
  80. </form>
  81. <div class="row">
  82. <h4>Region events:</h4>
  83. <ul>
  84. <li><code>region-in</code> – When playback enters a region. Callback will receive the <code>Region</code> object.</li>
  85. <li><code>region-out</code>– When playback leaves a region. Callback will receive the <code>Region</code> object.</li>
  86. <li><code>region-mouseenter</code> - When the mouse moves over a region. Callback will receive the <code>Region</code> object, and a <code>MouseEvent</code> object.</li>
  87. <li><code>region-mouseleave</code> - When the mouse leaves a region. Callback will receive the <code>Region</code> object, and a <code>MouseEvent</code> object.</li>
  88. <li><code>region-click</code> - When the mouse clicks on a region. Callback will receive the <code>Region</code> object, and a <code>MouseEvent</code> object.</li>
  89. <li><code>region-dblclick</code> - When the mouse double-clicks on a region. Callback will receive the <code>Region</code> object, and a <code>MouseEvent</code> object.</li>
  90. <li><code>region-created</code> – When a region is created. Callback will receive the <code>Region</code> object.</li>
  91. <li><code>region-updated</code> – When a region is updated. Callback will receive the <code>Region</code> object.</li>
  92. <li><code>region-update-end</code> – When dragging or resizing is finished. Callback will receive the <code>Region</code> object.</li>
  93. <li><code>region-removed</code> – When a region is removed. Callback will receive the <code>Region</code> object.</li>
  94. </ul>
  95. <h4>Regions Plugin</h4>
  96. <p>Regions are visual overlays on waveform that can be used to play and
  97. loop portions of audio. Regions can be dragged and resized.</p>
  98. <p>Visual customization is possible via CSS (using the selectors
  99. <code>.wavesurfer-region</code> and <code>.wavesurfer-handle</code>).</p>
  100. <p>To enable the plugin, add the script <code>plugin/wavesurfer.regions.js</code> to
  101. your page.</p>
  102. <p>After doing that, use <code>wavesurfer.addRegion()</code> to create Region objects.</p>
  103. <h5>Exposed Methods</h5>
  104. <ul>
  105. <li><code>addRegion(options)</code> – Creates a region on the waveform. Returns a <code>Region</code> object. See <a href="#region-options">Region Options</a>, <a href="#region-methods">Region Methods</a> and <a href="#region-events">Region Events</a> below.
  106. <ul>
  107. <li><strong>Note:</strong> You cannot add regions until the audio has finished loading, otherwise the <code>start:</code> and <code>end:</code> properties of the new region will be set to <code>0</code>, or an unexpected value.</li>
  108. </ul></li>
  109. <li><code>clearRegions()</code> – Removes all regions.</li>
  110. <li><code>enableDragSelection(options)</code> – Lets you create regions by selecting.
  111. areas of the waveform with mouse. <code>options</code> are Region objects' params (see <a href="#region-options">below</a>).</li>
  112. <li><code>disableDragSelection()</code> - Disables ability to create regions.</li>
  113. </ul>
  114. <h5>Region Options</h5>
  115. <table><thead>
  116. <tr>
  117. <th>option</th>
  118. <th>type</th>
  119. <th>default</th>
  120. <th>description</th>
  121. </tr>
  122. </thead><tbody>
  123. <tr>
  124. <td><code>id</code></td>
  125. <td>string</td>
  126. <td>random</td>
  127. <td>The id of the region.</td>
  128. </tr>
  129. <tr>
  130. <td><code>start</code></td>
  131. <td>float</td>
  132. <td><code>0</code></td>
  133. <td>The start position of the region (in seconds).</td>
  134. </tr>
  135. <tr>
  136. <td><code>end</code></td>
  137. <td>float</td>
  138. <td><code>0</code></td>
  139. <td>The end position of the region (in seconds).</td>
  140. </tr>
  141. <tr>
  142. <td><code>loop</code></td>
  143. <td>boolean</td>
  144. <td><code>false</code></td>
  145. <td>Whether to loop the region when played back.</td>
  146. </tr>
  147. <tr>
  148. <td><code>drag</code></td>
  149. <td>boolean</td>
  150. <td><code>true</code></td>
  151. <td>Allow/dissallow dragging the region.</td>
  152. </tr>
  153. <tr>
  154. <td><code>resize</code></td>
  155. <td>boolean</td>
  156. <td><code>true</code></td>
  157. <td>Allow/dissallow resizing the region.</td>
  158. </tr>
  159. <tr>
  160. <td><code>color</code></td>
  161. <td>string</td>
  162. <td><code>"rgba(0, 0, 0, 0.1)"</code></td>
  163. <td>HTML color code.</td>
  164. </tr>
  165. </tbody></table>
  166. <h5>Region Methods</h5>
  167. <ul>
  168. <li><code>remove()</code> - Remove the region object.</li>
  169. <li><code>update(options)</code> - Modify the settings of the region.</li>
  170. <li><code>play()</code> - Play the audio region from the start to end position.</li>
  171. </ul>
  172. <h5>Region Events</h5>
  173. <p>General events:</p>
  174. <ul>
  175. <li><code>in</code> - When playback enters the region.</li>
  176. <li><code>out</code> - When playback leaves the region.</li>
  177. <li><code>remove</code> - Happens just before the region is removed.</li>
  178. <li><code>update</code> - When the region's options are updated.</li>
  179. </ul>
  180. <p>Mouse events:</p>
  181. <ul>
  182. <li><code>click</code> - When the mouse clicks on the region. Callback will receive a <code>MouseEvent</code>.</li>
  183. <li><code>dblclick</code> - When the mouse double-clicks on the region. Callback will receive a <code>MouseEvent</code>.</li>
  184. <li><code>over</code> - When mouse moves over the region. Callback will receive a <code>MouseEvent</code>.</li>
  185. <li><code>leave</code> - When mouse leaves the region. Callback will receive a <code>MouseEvent</code>.</li>
  186. </ul>
  187. </div>
  188. <div class="footer row">
  189. <div class="col-sm-12">
  190. <a rel="license" href="https://opensource.org/licenses/BSD-3-Clause"><img alt="BSD-3-Clause License" style="border-width:0" src="https://img.shields.io/badge/License-BSD%203--Clause-blue.svg" /></a>
  191. </div>
  192. <div class="col-sm-8">
  193. <span xmlns:dct="http://purl.org/dc/terms/" href="http://purl.org/dc/dcmitype/Text" property="dct:title" rel="dct:type">wavesurfer.js</span> by <a href="https://github.com/katspaugh/wavesurfer.js">katspaugh</a> is licensed under a <a rel="license" href="https://opensource.org/licenses/BSD-3-Clause">BSD-3-Clause License</a>.
  194. </div>
  195. <div class="col-sm-4">
  196. <p>
  197. The sound file is from <a href="https://librivox.org/librivox-multilingual-short-works-collection-001-by-various/">librivox.org</a>.
  198. </p>
  199. </div>
  200. </div>
  201. </div>
  202. <div class="github-fork-ribbon-wrapper right">
  203. <div class="github-fork-ribbon">
  204. <a itemprop="isBasedOnUrl" href="https://github.com/katspaugh/wavesurfer.js">Fork me on GitHub</a>
  205. </div>
  206. </div>
  207. <script>
  208. (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
  209. (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
  210. m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
  211. })(window,document,'script','//www.google-analytics.com/analytics.js','ga');
  212. ga('create', 'UA-50026819-1', 'wavesurfer.fm');
  213. ga('send', 'pageview');
  214. </script>
  215. </body>
  216. </html>