Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

buffering_seeking_time_ranges

  window.onload = function(){

    var myAudio = document.getElementById('my-audio');
    var myCanvas = document.getElementById('my-canvas');
    var context = myCanvas.getContext('2d');

    context.fillStyle = 'lightgray';
    context.fillRect(0, 0, myCanvas.width, myCanvas.height);
    context.fillStyle = 'red';
    context.strokeStyle = 'white';

    var inc = myCanvas.width / myAudio.duration;

    // display TimeRanges

    myAudio.addEventListener('seeked', function() {
      for (i = 0; i < myAudio.buffered.length; i++) {

        var startX = myAudio.buffered.start(i) * inc;
        var endX = myAudio.buffered.end(i) * inc;
        var width = endX - startX;

        context.fillRect(startX, 0, width, myCanvas.height);
        context.rect(startX, 0, width, myCanvas.height);
        context.stroke();
      }
    });
  }
Comment

PREVIOUS NEXT
Code Example
Javascript :: js window selection get new line 
Javascript :: Add rows to the table dynamically with the use of vue.js 
Javascript :: How to make Jquery Class clickable 
Javascript :: if text is in curly braces replace to div site:stackoverflow.com 
Javascript :: how to make gamemaker games in javascript 
Javascript :: how to define an object in javascript 
Javascript :: one page nav cdn 
Javascript :: Entendendo Package Json e instalando o Express 
Javascript :: Comparison Primitive operations Methods 
Javascript :: useEffect es6 format 
Javascript :: Get value from ionRangeSlider in jquery 
Javascript :: change bg props 
Javascript :: format moment to (dd-mm-yyy hh:mm:ss 
Javascript :: how to go specific content in react single page by id 
Javascript :: how to ask for leave in js 
Javascript :: how to get mobile preferences is it dark or light using javascript 
Javascript :: set body angle matter.js 
Javascript :: Process.ChildProcess._handle.onexit 
Javascript :: internation number 
Javascript :: convert js to jquery online 
Javascript :: javascript refresh function every 5 seconds 
Javascript :: replacing value of arrayObj using map and spread operator 
Javascript :: how presist state in nuxt.js 
Javascript :: exercice json 
Javascript :: signed url to get file from s3 bucket 
Javascript :: convert string to charcode js 
Javascript :: get gravatar javascript 
Javascript :: react router 6 redirect 
Javascript :: forward slash in ajax url 
Javascript :: javasript vetical menu cog 
ADD CONTENT
Topic
Content
Source link
Name
1+1 =