index.html 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
  5. <title>wavesurfer.js | Media Element Example</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="screenshot" itemprop="screenshot" href="https://katspaugh.github.io/wavesurfer.js/example/screenshot.png" />
  12. <!-- wavesurfer.js -->
  13. <script src="../../dist/wavesurfer.js"></script>
  14. <script src="../../dist/plugin/wavesurfer.regions.js"></script>
  15. <!-- Demo -->
  16. <script src="main.js"></script>
  17. </head>
  18. <body itemscope itemtype="http://schema.org/WebApplication">
  19. <div class="container">
  20. <div class="header">
  21. <ul class="nav nav-pills pull-right">
  22. <li><a href="/"><i class="glyphicon glyphicon-home"></i></a></li>
  23. </ul>
  24. <h1 itemprop="name">Existing Media Element Example</h1>
  25. </div>
  26. <div id="demo">
  27. <div id="waveform">
  28. <!-- Here be the waveform -->
  29. </div>
  30. <div class="controls">
  31. <button class="btn btn-primary" data-action="play">
  32. <i class="glyphicon glyphicon-play"></i>
  33. Play
  34. /
  35. <i class="glyphicon glyphicon-pause"></i>
  36. Pause
  37. </button>
  38. </div>
  39. <video src="../media/demo_video.mp4" type="video/mpeg"></video>
  40. </div>
  41. <div class="row marketing">
  42. <h3>How to Enable the Fallback</h3>
  43. <hr />
  44. <p>
  45. You can choose to use an existing
  46. html5 audio or video element manually. Simply set the <code>backend</code>
  47. option to <code>"MediaElement"</code> and pass the media element as the first
  48. argument to wavesurfer.load(). Include an array of peaks as the second
  49. argument, the Web Audio API will not be used to render the peaks.
  50. </p>
  51. <p>
  52. <pre><code>var wavesurfer = WaveSurfer.create({
  53. container: document.querySelector('#waveform'),
  54. waveColor: '#A8DBA8',
  55. progressColor: '#3B8686',
  56. backend: 'MediaElement'
  57. });
  58. // Load audio from existing media element
  59. var mediaElt = document.querySelector('video');
  60. wavesurfer.load(mediaElt);</code></pre>
  61. </p>
  62. <h3>Pre-rendered Peaks</h3>
  63. <p>
  64. If you have pre-rendered peaks (on your server),
  65. you can pass them into the <code>load</code>
  66. function. This is optional–if you don't provide
  67. any peaks,
  68. <strong>waserver.js</strong> will first draw a
  69. thin line instead of a waveform, then attempt to
  70. download the audio file via Ajax and decode it
  71. with Web Audio if available.
  72. </p>
  73. <p>
  74. <pre><code>
  75. // init with an array of peak data.
  76. wavesurfer.load(mediaElt, [0.0218, 0.0183, 0.0165, 0.0198, 0.2137]);
  77. </code></pre>
  78. </p>
  79. <p>
  80. Press this button to see the same demo with pre-decoded peaks:
  81. <button class="btn btn-warning" data-action="peaks">
  82. Load with pre-rendered peaks
  83. </button>
  84. </p>
  85. </div>
  86. <div class="footer row">
  87. <div class="col-sm-12">
  88. <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>
  89. </div>
  90. <div class="col-sm-7">
  91. <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&nbsp;<a style="white-space: nowrap" rel="license" href="https://opensource.org/licenses/BSD-3-Clause">BSD-3-Clause License</a>.
  92. </div>
  93. <div class="col-sm-5">
  94. <div class="pull-right">
  95. <noindex>
  96. The audio file is from <a rel="nofollow" href="http://spokencorpora.ru/">spokencorpora.ru</a>, used with permission.
  97. </noindex>
  98. </div>
  99. </div>
  100. </div>
  101. </div>
  102. <div class="github-fork-ribbon-wrapper right">
  103. <div class="github-fork-ribbon">
  104. <a itemprop="isBasedOnUrl" href="https://github.com/katspaugh/wavesurfer.js">Fork me on GitHub</a>
  105. </div>
  106. </div>
  107. <script>
  108. (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
  109. (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
  110. m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
  111. })(window,document,'script','//www.google-analytics.com/analytics.js','ga');
  112. ga('create', 'UA-50026819-1', 'wavesurfer.fm');
  113. ga('send', 'pageview');
  114. </script>
  115. </body>
  116. </html>