Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HTMLMediaElement: The provided double value is non-finite

Tags:

javascript

Hello im trying to set a volume to a video!

When i try to set the volume like this:

myVideoElement.volume = 0.801; // Is working fine!

But when i try to set the volume like this:

var volumeToSet = Math.floor(myPrcent * 10) / 1000;

myVideoElement.volume = volumeToSet;

I get this error:

enter image description here How can fix that?

like image 376
John Stamoutsos Avatar asked Jan 24 '18 18:01

John Stamoutsos


2 Answers

Ok solved! I trying before to find the percentage of the video volume with:

var percent = Math.floor((left / Math.floor(myVideoElement.volume * 10) / 10) * 100);

The Math.floor() function makes my number infinity!

like image 130
John Stamoutsos Avatar answered Nov 04 '22 00:11

John Stamoutsos


I've received similar error when I was using IntersectionObserver. It turned out that the entries according to the documentation have to be less than 1. Somehow I put 2.5345453453 as an entry and got this error. I hope it'll help someone as well.

like image 30
Steve Reichbach Avatar answered Nov 04 '22 02:11

Steve Reichbach