Internet midi respects start and end times (#43021)

* Play Internet Sound respects start time
For example, adding &t=400 to youtube links.
Doesn't try to parse the start time, youtube-dl does that for us already. Will probably work on most sites not just youtube.

* [Play Internet Sound] now supports end time too

Switched event handler for start to loadeddata from canplay

loadeddata fires when the first frame is available
this is quicker and more consistent than canplay, which tries
to predict at least a few moments of playability being
available before it fires

* [Internet Sound] music_extra_data now starts null
This commit is contained in:
JJRcop
2019-03-08 10:51:04 -05:00
committed by Emmett Gaines
parent 1872bed67f
commit 8748e6d83e
3 changed files with 48 additions and 5 deletions
+4 -2
View File
@@ -67,7 +67,7 @@
if(istext(web_sound_input))
var/web_sound_url = ""
var/stop_web_sounds = FALSE
var/pitch
var/list/music_extra_data = list()
if(length(web_sound_input))
web_sound_input = trim(web_sound_input)
@@ -95,6 +95,8 @@
var/webpage_url = title
if (data["webpage_url"])
webpage_url = "<a href=\"[data["webpage_url"]]\">[title]</a>"
music_extra_data["start"] = data["start_time"]
music_extra_data["end"] = data["end_time"]
var/res = alert(usr, "Show the title of and link to this song to the players?\n[title]",, "No", "Yes", "Cancel")
switch(res)
@@ -126,7 +128,7 @@
var/client/C = M.client
if((C.prefs.toggles & SOUND_MIDI) && C.chatOutput && !C.chatOutput.broken && C.chatOutput.loaded)
if(!stop_web_sounds)
C.chatOutput.sendMusic(web_sound_url, pitch)
C.chatOutput.sendMusic(web_sound_url, music_extra_data)
else
C.chatOutput.stopMusic()