Permission to enable audio visualiser.
Temporarily accept audio permission to enable audio visualiser. It will switch off immediately.
This example demonstrates the audio meter display working while muted and autoplay using mediadevice hacks to work around autoplay restrictions. Hacks have been added to display modal windows when requesting to temporarily request and capture a microphone device which will be turned off immediately using the usemediadevice
config. Capturing a microphone media device completely works around autoplay mute and audio context suspended state restructions requiring user gesture. Like with the WebRTC features.
Microphone devices will only be requested if the context is still suspended.
A seperate tiny tailwind css file is included for the modal window styles but it can be any framework.
NOTE: User gesture confirmed is working if navigating to a page with a link in Chrome so these autoplay work arounds may not be needed. Firefox does not recognise navigated link user gesture.
NOTE: Due to an oversight allowing autoplay audio contexts which is required for audio analysers to work. And no permission api was added for audio contexts which means the permission can be saved for the site. A modal window can be displayed to notify first requesting a microphone media device. And if that fails it will keep requesting user gesture clicks in another fallback modal window.
To notify requesting microphones, the Permission api is used to detect it prompting the user. Firefox and Safari have no Permission API ability to detect accepted microphone devices so a work around has been added to the work around using localstorage to detect if a device has been accepted. Using localstorage is once off and won't know if device prompts is re-requested.
Safari may still fail to autoplay due to requiring the video element to be unmuted to capture audio data for the analyser.
Requesting mediadevices on a domain require to be served under HTTPS to work.
<div class="flex w-full h-auto my-auto">
<div id="autoplay-mediadevice" class=""></div>
</div>
<script type="text/javascript">
var player = jwplayer("autoplay-mediadevice").setup({
"aspectratio": "16:9",
"autostart": true,
"mute": true,
"playbackRateControls": true,
"plugins": {
"../../js/audiovisualiser-8.1.0.js": {
"mutable": true,
"usemediadevice": true
}
},
"sources": [
{
"file": "https://videos.electroteque.org/bitrate/elephants_dream_2000k.webm",
"type": "webm"
},
{
"file": "https://videos.electroteque.org/bitrate/elephants_dream_2000k.mp4",
"type": "mp4"
}
],
"width": "100%"
});
</script>