S
S
San0072020-05-12 21:55:53
JavaScript
San007, 2020-05-12 21:55:53

How to keep volume level in video on page reload?

Good evening.
The video tag has "controls" hidden.
Added their own control styles.

<input type="range" step="0.1" min="0" max="1" value="1" id="volume" />

volumeControl.addEventListener('input', function () {
    videoView.volume = volumeControl.value;
}, false);


Is it possible to keep the volume level on page reload?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
J
Jedi, 2020-05-12
@PHPjedi

Save to LocalStorage.
We write a listener and listen, when the volume value in the player is updated, we execute the following code/command: When loading the page, check if the volume key is in localStorage... For skills: https://learn.javascript.ru/localstorage Example with code here in case anyone needs it in the future. localStorage.setItem('volume', ЗНАЧЕНИЕ);
localStorage.getItem('volume');

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question