-
-
Save Barteks2x/a4e189a36a10c159bb1644ffca21c02a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function() { | |
'use strict'; | |
const {get, set} = Object.getOwnPropertyDescriptor(HTMLMediaElement.prototype, 'volume'); | |
Object.defineProperty(HTMLMediaElement.prototype, 'volume', { | |
get () { | |
const volume = get.call(this); | |
const newVolume = Math.pow(volume, 1./3.); | |
console.log('manipulated volume from', volume, 'to ', newVolume, 'on', this); | |
return newVolume; | |
}, | |
set (volume) { | |
// same as https://github.com/pulseaudio/pulseaudio/blob/19adddee31ca34bf4e0db95df01b4ec595f2d267/src/pulse/volume.c#L265-L275 | |
// https://www.robotplanet.dk/audio/audio_gui_design/ | |
const player = document.getElementById('movie_player'); | |
if (player) { | |
volume = player.getVolume() * 0.01; | |
} | |
const newVolume = volume*volume*volume; | |
console.log('manipulated volume to ', newVolume, ' from', volume, 'on', this); | |
return set.call(this, newVolume); | |
} | |
}); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment