Last active
August 29, 2015 14:24
-
-
Save mcpower/65d80715c402a615b768 to your computer and use it in GitHub Desktop.
osu! HTML5 audio playback
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
// ==UserScript== | |
// @name osu! HTML5 audio playback | |
// @namespace http://your.homepage/ | |
// @version 0.1 | |
// @description Replaces the osu! Flash audio preview with an HTML5 one. | |
// @author mcpower | |
// @match https://osu.ppy.sh/p/beatmaplist* | |
// @match https://osu.ppy.sh/s/* | |
// @match https://osu.ppy.sh/b/* | |
// @grant none | |
// ==/UserScript== | |
window.audio = new Audio(); | |
window.audio.volume = 0.45; | |
window.play = function play(id, iscallback) | |
{ | |
if (!audio.paused && playingid == id){ | |
audio.pause(); | |
audio.currentTime = 0; | |
return false; | |
} | |
playingid = id; | |
audio.src = STATIC_DOMAIN_BEATMAP + "/preview/" + id + ".mp3"; | |
audio.play() | |
return true; | |
} | |
window.audio.onended = function() { | |
$('.bmlistt>.icon-pause').removeClass("icon-pause").addClass("icon-play"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment