0

I'm currently working on an audio player based on the html5 audio tag using javascript for a project. I am asked to handle audio quality (as you would see on YouTube for videos). I guess, the only way to do it is to have multiple source files (for instance a SQ mp3 + HQ mp3 / SQ ogg + HQ ogg + wav) and change it with javascript, but I was wondering how, and if it was the best option.

Any help would be appreciated. Thanks !

Théo Winterhalter
  • 3,762
  • 2
  • 16
  • 33
  • you compare apples to oranges. audio uses FAR less bandwidth than youtube videos (especially hd), so the demand/need is not the same. – dandavis Sep 06 '13 at 20:11
  • Well, maybe, but I was talking about the principle, I'd like to add a button triggering the change of the audio file. Don't you think it's the right way to do it ? (Audio quality really matters in that project I'm working on) – Théo Winterhalter Sep 06 '13 at 22:15
  • Doing it seamlessly would be a far more complex problem, but the simplest solution would be to: 1) keep track of current audio time. 2) on quality change, switch source to the desired one 3) play the new source from the last measured time – kyler Nov 30 '15 at 15:58

1 Answers1

0

Manual selection of changing the quality is just a matter of:

  1. Saving the currentTime in a variable.
  2. setting the audio src to the URL of a different audio (with the same content at a different quality).
  3. Setting the currentTime to the value in the variable.
  4. Playing the audio.

And these all you can do with javascript or jquery.

To Change src to high quality file,this will help you.

Community
  • 1
  • 1
SreYash
  • 111
  • 3