6

How to stop downloading audio file to browser in HTML5 audio tag controls when pause is pressed?

torayeff
  • 9,296
  • 19
  • 69
  • 103
  • 1
    Take a look at the `206 http-status code`. Maybe that helps – Nano Jan 21 '15 at 13:42
  • @Nano 206 looks like a good option, but we need to control the server to honor such requests. If it's a third party media server, we don't have much of a choice. – asgs May 19 '15 at 05:59

1 Answers1

1

This will work:

var audio = $("audio").get(0);
audio.pause(0);
var tmp = audio.src;
audio.src = "";
audio.load();
$("audio").remove();
$("#audio-player").html("<audio controls preload='none'></audio>");
audio = $("audio").get(0);
audio.src = tmp;
audio.addEventListener('pause', current-function);

Here is a link for you to follow : HTML5 Video: Force abort of buffering

Community
  • 1
  • 1
Victor Juliet
  • 1,052
  • 11
  • 21
  • Since the video is alreadyn downloading because "pause" was pressed no audio tag will stop downloading. Preload is only for the start when the audio tag is displayed ... caveat is you do not know how long the video is. – Jobst May 19 '15 at 05:13
  • If the flash player is used, then this becomes quite easy with the user (client) specifying how much to buffer in addition to the already loaded audio (video). By default it is only a few kilobytes of data which is usually downloaded by the flash player. – Victor Juliet May 19 '15 at 05:39