mirror of
https://github.com/CHOMPStation2/CHOMPStation2.git
synced 2025-12-11 10:43:20 +00:00
Ports media code from vgstation, updates it for this codebase and modernizes it. * Changes jukeboxes to load songs using an embedded browser instead of sending over BYOND's sound channels. This means they load out of band without lagging the server. Also songs can be resumed mid-song, so leaving and returning to an area doesn't start the music over. * The old WMP and VLC player modes from /vg are still supported, but adds a new default mode using HTML5 audio to play the music. * WMP - The oldest, still works on IE on windows, but only there, and Microsoft could break it any second. * VLC - Works on all platforms, but requires user to have VLC pre-installed on their computer. Uses a scary plugin. * HTML5 - New default, It is cross platform but doesn't require you to have VLC installed to work. Also caches songs locally even between rounds. * Changed jukebox.txt to be jukebox.json, now can include artist information as well. Must include the duration of songs as well. * For HTML5 audio compatibility, use only MP3 files, its the only format supported on all browsers. * Jukebox itself is also upgraded, instead of just repeating the same song over and over it can actually advance to the next song when one is done playing. Has a few modes including random, next, and single song. * Jukeboxes have a UI improvement, and have a volume control. * Three new settings are added to global settings in character setup * Jukebox music on/off toggles jukebox music independently of normal station ambience. Now you can hear ambience but not music. (or vice versa if you wanted...) * Jukebox music volume. Control the relative volume of jukebox music. Actual volume is player's configured volume * jukebox's configured volume. * Media player type. Choose between WMP, VLC, and HTML5 * Fixes a few bugs in the /vg code.
54 lines
2.7 KiB
Plaintext
54 lines
2.7 KiB
Plaintext
/datum/preferences
|
|
var/media_volume = 1
|
|
var/media_player = 2 // 0 = VLC, 1 = WMP, 2 = HTML5, 3+ = unassigned
|
|
|
|
/datum/category_item/player_setup_item/player_global/media
|
|
name = "Media"
|
|
sort_order = 6
|
|
|
|
/datum/category_item/player_setup_item/player_global/media/load_preferences(var/savefile/S)
|
|
S["media_volume"] >> pref.media_volume
|
|
S["media_player"] >> pref.media_player
|
|
|
|
/datum/category_item/player_setup_item/player_global/media/save_preferences(var/savefile/S)
|
|
S["media_volume"] << pref.media_volume
|
|
S["media_player"] << pref.media_player
|
|
|
|
/datum/category_item/player_setup_item/player_global/media/sanitize_preferences()
|
|
pref.media_volume = isnum(pref.media_volume) ? Clamp(pref.media_volume, 0, 1) : initial(pref.media_volume)
|
|
pref.media_player = sanitize_inlist(pref.media_player, list(0, 1, 2), initial(pref.media_player))
|
|
|
|
/datum/category_item/player_setup_item/player_global/media/content(var/mob/user)
|
|
. += "<b>Jukebox Volume:</b>"
|
|
. += "<a href='?src=\ref[src];change_media_volume=1'><b>[round(pref.media_volume * 100)]%</b></a><br>"
|
|
. += "<b>Media Player Type:</b> Depending on you operating system, one of these might work better. "
|
|
. += "Use HTML5 if it works for you. If neither HTML5 nor WMP work, you'll have to fall back to using VLC, "
|
|
. += "but this requires you have the VLC client installed on your comptuer."
|
|
. += "Try the others if you want but you'll probably just get no music.<br>"
|
|
. += (pref.media_player == 2) ? "<span class='linkOn'><b>HTML5</b></span> " : "<a href='?src=\ref[src];set_media_player=2'>HTML5</a> "
|
|
. += (pref.media_player == 1) ? "<span class='linkOn'><b>WMP</b></span> " : "<a href='?src=\ref[src];set_media_player=1'>WMP</a> "
|
|
. += (pref.media_player == 0) ? "<span class='linkOn'><b>VLC</b></span> " : "<a href='?src=\ref[src];set_media_player=0'>VLC</a> "
|
|
. += "<br>"
|
|
|
|
/datum/category_item/player_setup_item/player_global/media/OnTopic(var/href, var/list/href_list, var/mob/user)
|
|
if(href_list["change_media_volume"])
|
|
if(CanUseTopic(user))
|
|
var/value = input("Choose your Jukebox volume (0-100%)", "Jukebox volume", round(pref.media_volume * 100))
|
|
if(isnum(value))
|
|
value = Clamp(value, 0, 100)
|
|
pref.media_volume = value/100.0
|
|
if(user.client && user.client.media)
|
|
user.client.media.update_volume(pref.media_volume)
|
|
return TOPIC_REFRESH
|
|
else if(href_list["set_media_player"])
|
|
if(CanUseTopic(user))
|
|
var/newval = sanitize_inlist(text2num(href_list["set_media_player"]), list(0, 1, 2), pref.media_player)
|
|
if(newval != pref.media_player)
|
|
pref.media_player = newval
|
|
if(user.client && user.client.media)
|
|
user.client.media.open()
|
|
spawn(10)
|
|
user.update_music()
|
|
return TOPIC_REFRESH
|
|
return ..()
|