Im trying to make a script to fade off the volume of a html5 video.

So I found a code to make it and I make some changes to fit my needs, getting something like this.

```js
 var videoMute = $('#myVideo').get(0);
 var heightVideo = parseInt( $("#contents-main").css("marginTop") );

 $(document).scroll(function() {
  videoMute.volume = 1 - $(window).scrollTop() / heightVideo;
 });
```

So Im trying to fade the volume of the video when the user scroll some margintop that I have between the content and the video, them I try to calculate the video volume between the windows scroll top and the margin that I get from the content main.

The issue is that Im getting this error when I scroll the margin and enter in the #content-main.

```
    Uncaught DOMException: Failed to set the volume property on HTMLMediaElement: The volume provided -X number is outside the range 0, 1.

```

Maybe you can help me to fix this issue with some advice of how to end the function when the volume gets minus than cero, or maybe changing the way that I formulate the math formule to gets the video volume.

Thanks in advance.