Created
July 8, 2017 01:07
-
-
Save anonymous/3952627742270ebb034001d1e6df7c2e 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
var play_ms = 30000; | |
// fade_partitions * fade_interval_ms = totalms | |
// フェードアウトの短くしたいならfade_partitionsの方をいじるのを推奨 | |
// 長くしたい時は逆 | |
var fade_interval_ms = 100; | |
var fade_partitions = 100; | |
var mute_ms = 2000; | |
//timer_id | |
var playtimer_id; | |
var fadetimer_id; | |
var muitetimer_id; | |
function on_playback_new_track(metadb) { | |
fb.Volume = 0; | |
playtimer_id = window.SetTimeout(function() { | |
script_fadeout(); | |
window.ClearTimeout(playtimer_id); | |
}, play_ms); | |
} | |
function script_fadeout(){ | |
var fade_counter = 1; | |
fadetimer_id = window.SetInterval(function() { | |
// fb.Volume(-100 to 0) | |
fb.Volume = 0 - 100 / fade_partitions * fade_counter; | |
if(fade_counter++ >= fade_partitions){ | |
fb.Stop(); | |
script_mute(); | |
} | |
}, fade_interval_ms); | |
} | |
function script_mute(){ | |
muitetimer_id = window.SetTimeout(function() { | |
fb.Volume = 0; | |
fb.Next(); | |
window.ClearTimeout(muitetimer_id); | |
}, mute_ms); | |
} | |
// 再生停止でスクリプト実行停止 | |
function on_playback_stop() { | |
stop_function(); | |
} | |
// 再生一時停止でスクリプト実行停止 | |
function on_playback_pause() { | |
stop_function(); | |
} | |
// パネル右クリックでスクリプト実行停止 | |
function on_mouse_lbtn_down() { | |
stop_function(); | |
} | |
function stop_function(){ | |
window.ClearTimeout(playtimer_id); | |
window.ClearInterval(fadetimer_id); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment