Guest User

Untitled

a guest
Dec 11th, 2017
194
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 2.07 KB | None | 0 0
  1. <script>
  2. // generalized script
  3. // should only be included once in the page
  4. jQuery(function() {
  5.     $(.audio-panel').on('click', function() {
  6.         $(this).find('audio').get(0).play();
  7.     });
  8.  
  9.     function checkStatus() {
  10.         var audioElements = $('.audio-panel audio');
  11.         audioElements.forEach(function() {
  12.             var displayElement = $(this).closest('.panel-body').find('.display-status'),
  13.                 buffered = this.buffered,
  14.                 loaded;
  15.  
  16.             if (buffered.length) {
  17.                 loaded = 100 * buffered.end(0) / this.duration;
  18.                 if (loaded.toFixed(2) !== '0.00') {
  19.                     displayElement.text('Loading: ' + loaded.toFixed(2) + '%');
  20.                 }
  21.  
  22.                 if (loaded >= 1) {$(this).removeClass('un-buffered');}
  23.             } else {
  24.                 displayElement.text('Loading...')
  25.             }
  26.         });
  27.     }
  28.    
  29.     setInterval(checkStatus, 50);
  30. });
  31. </script>
  32.  
  33. <!--
  34.    following html structure to work with above script
  35.    should remove ID properties and add the classes
  36.  
  37. -->
  38.             <div class="panel-group audio-panel" id="accordion8o" type="button">
  39.                 <div class="panel panel-default" data-toggle="collapse" data-parent="#accordion8o" href="#eight1">
  40.                     <div class="panel-heading">
  41.                         <h4 class="panel-title">
  42.                             &#2321;&#2337;&#2367;&#2351;&#2379; &#2344;&#2306;&#2348;&#2352; 8 &#2357;&#2360;&#2369;&#2350;&#2340;&#2368;(&#2408;)
  43.                         </h4>
  44.                     </div>
  45.                     <div id="eight1" class="panel-collapse collapse">
  46.                         <div class="panel-body">
  47.                             <audio controls="controls">
  48.                                 <source src="https://docs.google.com/uc?export=download&id=19TMRZ1wM-XNuDIkZzSDF3Y8tf1piKoMv">
  49.                             </audio>
  50.                             <p><span class="display-status"></span></p>
  51.                         </div>
  52.                     </div>
  53.                 </div>
  54.             </div>
  55. <script>
Advertisement
Add Comment
Please, Sign In to add comment