Skip to content

Instantly share code, notes, and snippets.

@mcpower
Last active August 29, 2015 14:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mcpower/65d80715c402a615b768 to your computer and use it in GitHub Desktop.
Save mcpower/65d80715c402a615b768 to your computer and use it in GitHub Desktop.
osu! HTML5 audio playback
// ==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