index.html 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
  5. <title>wavesurfer.js | Media Sesssion plugin</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. <!-- wavesurfer.js -->
  12. <script src="../../dist/wavesurfer.min.js"></script>
  13. <!-- media session plugin -->
  14. <script src="../../dist/plugin/wavesurfer.mediasession.min.js"></script>
  15. <!-- App -->
  16. <script src="app.js"></script>
  17. </head>
  18. <body itemscope itemtype="http://schema.org/WebApplication">
  19. <div class="container">
  20. <div class="header">
  21. <h1 itemprop="name"><a href="http://wavesurfer-js.org">wavesurfer.js</a><noindex> + Media Session API</noindex></h1>
  22. </div>
  23. <div id="demo">
  24. <div id="waveform"></div>
  25. <div class="controls">
  26. <button class="btn btn-primary" data-action="play">
  27. <i class="glyphicon glyphicon-play"></i>
  28. Play
  29. /
  30. <i class="glyphicon glyphicon-pause"></i>
  31. Pause
  32. </button>
  33. </div>
  34. <audio src='../media/demo.wav' controls />
  35. </div>
  36. <div class="row marketing">
  37. <div class="col-lg-4">
  38. <h4>wavesurfer.js Media Session Plugin</h4>
  39. <p itemprop="about">The <a href='https://wicg.github.io/mediasession/' target='blank'>Media Session API</a> plugin for <strong>wavesurfer.js</strong> allows you to customize media notifications
  40. by providing metadata for the media your web app is playing. It also allows you to handle media related events such as
  41. seeking or playback which may come from notifications or media keys.</p>
  42. <p><strong>Note</strong>: this plugin only works in Chrome 57 and newer (Firefox is <a href='https://bugzilla.mozilla.org/show_bug.cgi?id=1112032' target='blank'>working on it</a>).</p>
  43. <h4>Installation</h4>
  44. <p>
  45. <ol>
  46. <li>add the MediaSession plugin script tag</li>
  47. <li>create a <code>WaveSurfer</code> instance and supply an object for the <code>metadata</code> property</li>
  48. <li>create a <code>MediaSession</code> instance</li>
  49. <li>control playback from the notification screen on a mobile device</li>
  50. </ol>
  51. </p>
  52. <p>
  53. <a class="btn btn-large btn-success" href="../../plugin/wavesurfer.mediasession.js" itemprop="downloadUrl">Download <strong>the plugin</strong> (1.2 KB)</a>
  54. </p>
  55. </div>
  56. <div class="col-lg-8">
  57. <h4>Quick Start</h4>
  58. <noindex><p>
  59. <pre><code>var wavesurfer = Object.create(WaveSurfer);
  60. wavesurfer.init({
  61. container : '#waveform',
  62. waveColor : 'black',
  63. backend : 'MediaElement'
  64. });
  65. var msPlugin = Object.create(WaveSurfer.MediaSession);
  66. msPlugin.init({
  67. wavesurfer: wavesurfer,
  68. metadata: {
  69. title: 'Wavesurfer.js Example',
  70. artist: 'The Wavesurfer.js Project',
  71. album: 'Media Session Example',
  72. artwork: [
  73. {src: 'https://dummyimage.com/96x96', sizes: '96x96', type: 'image/png'},
  74. {src: 'https://dummyimage.com/128x128', sizes: '128x128', type: 'image/png'},
  75. {src: 'https://dummyimage.com/192x192', sizes: '192x192', type: 'image/png'},
  76. {src: 'https://dummyimage.com/256x256', sizes: '256x256', type: 'image/png'},
  77. {src: 'https://dummyimage.com/384x384', sizes: '384x384', type: 'image/png'},
  78. {src: 'https://dummyimage.com/512x512', sizes: '512x512', type: 'image/png'},
  79. ]
  80. }
  81. });
  82. // load audio from existing media element
  83. var mediaElt = document.querySelector('audio');
  84. wavesurfer.load(mediaElt);
  85. </code></pre>
  86. </p></noindex>
  87. <br />
  88. <h4>Options</h4>
  89. <table class="table table-striped table-bordered">
  90. <thead>
  91. <tr>
  92. <th>Name</th>
  93. <th>Required</th>
  94. <th>Default</th>
  95. <th>Description</th>
  96. </tr>
  97. </thead>
  98. <tbody>
  99. <tr>
  100. <td><code>wavesurfer</code></td>
  101. <td>yes</td>
  102. <td></td>
  103. <td>A WaveSurfer instance.</td>
  104. </tr>
  105. <tr>
  106. <td><code>metadata</code></td>
  107. <td>yes</td>
  108. <td></td>
  109. <td>A <a href='https://wicg.github.io/mediasession/#mediametadata' target='blank'>MediaMetadata</a> object: a representation of the metadata associated with a MediaSession that can be used by
  110. user agents to provide customized user interface.</td>
  111. </tr>
  112. </tbody>
  113. </table>
  114. </div>
  115. </div>
  116. <div class="footer row">
  117. <div class="col-sm-12">
  118. <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>
  119. </div>
  120. <div class="col-sm-12">
  121. <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>.
  122. </div>
  123. </div>
  124. </div>
  125. <div class="github-fork-ribbon-wrapper right">
  126. <div class="github-fork-ribbon">
  127. <a itemprop="isBasedOnUrl" href="https://github.com/katspaugh/wavesurfer.js">Fork me on GitHub</a>
  128. </div>
  129. </div>
  130. <script>
  131. (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
  132. (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
  133. m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
  134. })(window,document,'script','//www.google-analytics.com/analytics.js','ga');
  135. ga('create', 'UA-50026819-1', 'wavesurfer.fm');
  136. ga('send', 'pageview');
  137. </script>
  138. </body>
  139. </html>