From 41af6ec137ebdac8a26f00d599121f7ac52bd052 Mon Sep 17 00:00:00 2001
From: SomeRandomOwl <2568378+SomeRandomOwl@users.noreply.github.com>
Date: Thu, 19 Jan 2023 14:39:19 -0600
Subject: [PATCH] Update the Play Internet Sound Verb (#72805)
## About The Pull Request
This changes it to expose additional metadata as well as remove unused
Metadata that wasn't provided by youtube-dl, It also changes the widget
itself to display a little extra info on the currently playing track.
Also adds in a new prompt to either show or hide the name of the admin
who played the music
## Why It's Good For The Game
It will now show additional info to players when a admin plays a song
using the verb, such as making the link always available to the player
so if they like the song they dont need to ask for the link, as well as
other info that might be scraped by youtube-dl so players know if you
simply queued a 2 minute long song or a 10 minute long one as well other
simple info such as artist and album if that info is available.
And now there is the option to show players who played songs, or to keep
it anonymous
Screenshots





## Changelog
:cl:
admin: Modified the Play Internet Sound Verb so it now displays extra
info about any song being actively played as well as showing the link
/:cl:
Co-authored-by: san7890
Co-authored-by: Fikou <23585223+Fikou@users.noreply.github.com>
---
code/modules/admin/verbs/playsound.dm | 26 ++++++++-
.../tgui-panel/audio/NowPlayingWidget.js | 58 ++++++++++++-------
2 files changed, 61 insertions(+), 23 deletions(-)
diff --git a/code/modules/admin/verbs/playsound.dm b/code/modules/admin/verbs/playsound.dm
index b27651a0020..b1031a38fa1 100644
--- a/code/modules/admin/verbs/playsound.dm
+++ b/code/modules/admin/verbs/playsound.dm
@@ -113,15 +113,35 @@
var/webpage_url = title
if (data["webpage_url"])
webpage_url = "[title]"
- music_extra_data["start"] = data["start_time"]
- music_extra_data["end"] = data["end_time"]
+ music_extra_data["duration"] = DisplayTimeText(data["duration"] * 1 SECONDS)
music_extra_data["link"] = data["webpage_url"]
+ music_extra_data["artist"] = data["artist"]
+ music_extra_data["upload_date"] = data["upload_date"]
+ music_extra_data["album"] = data["album"]
var/res = tgui_alert(usr, "Show the title of and link to this song to the players?\n[title]",, list("No", "Yes", "Cancel"))
switch(res)
if("Yes")
music_extra_data["title"] = data["title"]
- to_chat(world, span_boldannounce("An admin played: [webpage_url]"), confidential = TRUE)
+ if("No")
+ music_extra_data["link"] = "Song Link Hidden"
+ music_extra_data["title"] = "Song Title Hidden"
+ music_extra_data["artist"] = "Song Artist Hidden"
+ music_extra_data["upload_date"] = "Song Upload Date Hidden"
+ music_extra_data["album"] = "Song Album Hidden"
+ if("Cancel")
+ return
+
+ var/anon = tgui_alert(usr, "Display who played the song?", "Credit Yourself?", list("No", "Yes", "Cancel"))
+ switch(anon)
+ if("Yes")
+ if(res == "Yes")
+ to_chat(world, span_boldannounce("[src] played: [webpage_url]"), confidential = TRUE)
+ else
+ to_chat(world, span_boldannounce("[src] played some music"), confidential = TRUE)
+ if("No")
+ if(res == "Yes")
+ to_chat(world, span_boldannounce("An admin played: [webpage_url]"), confidential = TRUE)
if("Cancel")
return
diff --git a/tgui/packages/tgui-panel/audio/NowPlayingWidget.js b/tgui/packages/tgui-panel/audio/NowPlayingWidget.js
index 672ecfad7ce..aeef414ec00 100644
--- a/tgui/packages/tgui-panel/audio/NowPlayingWidget.js
+++ b/tgui/packages/tgui-panel/audio/NowPlayingWidget.js
@@ -6,33 +6,51 @@
import { toFixed } from 'common/math';
import { useDispatch, useSelector } from 'common/redux';
-import { Button, Flex, Knob } from 'tgui/components';
+import { Button, Collapsible, Flex, Knob } from 'tgui/components';
import { useSettings } from '../settings';
import { selectAudio } from './selectors';
export const NowPlayingWidget = (props, context) => {
- const audio = useSelector(context, selectAudio);
- const dispatch = useDispatch(context);
- const settings = useSettings(context);
- const title = audio.meta?.title;
+ const audio = useSelector(context, selectAudio),
+ dispatch = useDispatch(context),
+ settings = useSettings(context),
+ title = audio.meta?.title,
+ URL = audio.meta?.link,
+ Artist = audio.meta?.artist || 'Unknown Artist',
+ upload_date = audio.meta?.upload_date || 'Date Unknown',
+ album = audio.meta?.album || 'Unknown Album',
+ duration = audio.meta?.duration,
+ date = !isNaN(upload_date)
+ ? upload_date?.substring(0, 4) +
+ '-' +
+ upload_date?.substring(4, 6) +
+ '-' +
+ upload_date?.substring(6, 8)
+ : upload_date;
+
return (
{(audio.playing && (
- <>
-
- Now playing:
-
-
- {title || 'Unknown Track'}
-
- >
+
+ {
+
+
+ Url: {URL}
+ Duration: {duration}
+ Artist: {Artist}
+ Album: {album}
+ Uploaded: {date}
+
+
+ }
+
)) || (
Nothing to play.