Last active
January 15, 2018 09:51
-
-
Save miyaoka/486ab3cef9598ae80df134b1f5f40450 to your computer and use it in GitHub Desktop.
Set playbackRate on hearthis.at
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() { | |
const sm = window.soundManager | |
const soundId = sm.soundIDs[0] | |
const playBackward = -15 | |
const askPlaybackRate = () => { | |
console.log(sm.getSoundById(soundId)) | |
sm.setPlaybackRate( | |
soundId, | |
window.prompt('set playbackRate', sm.getSoundById(soundId).playbackRate || 1) || 1 | |
) | |
} | |
const setPosition = (sec) => { | |
sm.setPosition(soundId, sm.getSoundById(soundId).position + sec * 1000) | |
} | |
const onKeydown = (e) => { | |
if (e.key !== 'F12') return | |
setPosition(playBackward) | |
} | |
if (soundId) { | |
askPlaybackRate() | |
window.addEventListener('keydown', onKeydown) | |
} else { | |
alert('no sound') | |
} | |
})() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment