Shwetha R S
Shwetha R S

Reputation: 119

How to find system's audio driver status onloading of html5 page

I have a HTML5 page which has voice-over. It is playing the video perfectly on loading the page. I need to check the system's audio driver status, If it is disabled, i need to pop a message box saying "Audio driver is disabled". If it is enabled nothing to do.

My HTML5 code to add audio.

<audio preload="auto" id="Scene 1.0"><source src="sounds/Scene 1.0.mp3"></audio>

Upvotes: 1

Views: 535

Answers (2)

Kaiido
Kaiido

Reputation: 136658

You cannot (yet) get the audio outputs from HTMLMediaElement.

However, you can try creating a new AudioContext (browser compatibility), then check its destination property. I believe that if the maxChannelCountproperty is less than 1, then the driver is not instantiated.

function check_audioOut(){
  if(!window.AudioContext) return 'not accessible';
  var audioCtx = new AudioContext();
  return (audioCtx.destination.maxChannelCount>0)?'enabled': 'disabled';
  }

document.body.innerHTML = 'audio driver ' + check_audioOut(); 

Note that you won't be able to check if it is muted or not.

Upvotes: 3

michelem
michelem

Reputation: 14590

You could take a look at the Audio API, but I don't think they can know if the audio driver is present and working on the system. Then you should look at the browser compatibility that I think it's not available for old ones.

Upvotes: -1

Related Questions