Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allows MP3 files to be uploaded to the TGchat player - renames play internet sound #28575

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

Bm0n
Copy link
Contributor

@Bm0n Bm0n commented Mar 2, 2025

What Does This PR Do

A port of cmss13-devs/cmss13#4934

Renames Play Internet Sound to Play Global Sound TGchat.

Allows MP3 files to be uploaded to the cached CDN webroot server and played back via the TGchat player

Doing this should significantly cut back on lag as now every client doesn't need to download a sound when played.

This is all assuming the CDN is properly set up and the config asset_transport is set to webroot(as is required for the CDN to even function). The code defaults back to sending sound directly to clients if the CDN is down which lags all the same as the old proc. There's also an in-game warning for admins who try to upload an MP3 when the CDN is down.

Playing web sounds still exists it's just wrapped into one proc now.

Part of me wants to nuke the old Play Global Sound proc and I might still do that after this is TM'd or verified to be working well... Play Global Sound TGchat is kind of an awkward name.

Why It's Good For The Game

Almost lag free uploading and playing back of sounds.

Images of changes

pr1

CDN server caching uploaded MP3
pr2

Testing

Uploaded a bunch of MP3s using the localhost-asset-webroot-server.py tool and tested the hell out of the proc


Declaration

  • I confirm that I either do not require pre-approval for this PR, or I have obtained such approval and have included a screenshot to demonstrate this below.

Changelog

🆑 bmon, fira
tweak: 'Play Internet Sounds' renamed to 'Play Global Sound TGchat'
add: MP3 files can now be played using the renamed 'Play Global Sound TGchat' for nearly lag free playback of sounds
/:cl:

@ParadiseSS13-Bot ParadiseSS13-Bot added the -Status: Awaiting type assignment This PR is waiting for its type to be assigned internally label Mar 3, 2025
@Bm0n
Copy link
Contributor Author

Bm0n commented Mar 3, 2025

I am once again requesting a TM. There's no way for me to know how well this performs without sending an MP3 to 50 or so real players

Copy link
Contributor

@Drsmail Drsmail left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code logick and syntax looks good.

return

web_sound_input = tgui_input_text(src, "Enter content URL", "Play Internet Sound", null)
if(!istext(web_sound_input) || !length(web_sound_input))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could it be something beside text if we get this from tgui-text-input?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Like if you hit the X button on the input instead of submit?

Nothing, it has no length, it'll return.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I could get away with just !length, CM was doing both !istext and !length here so copied it over to be safer than sorry

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe !istext() will be enough

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

opposite actually. !length will return but !istext will not return it if a blank input is sent

media_poll_request.prepare(RUSTG_HTTP_METHOD_GET, GLOB.configuration.system.ytdlp_url, json_encode(request_body))
// Start it off and wait
media_poll_request.begin_async()
UNTIL(media_poll_request.is_complete())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As a complete noob, what will happen if we newer get an answer from server? Will we wait forever or will we fall into catch?

Copy link
Contributor Author

@Bm0n Bm0n Mar 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The web side of the code is mostly done by Affected and is unchanged from play internet sound

It'll runtime on into_response and give you back a yt-dlp URL retrieval FAILED error.
I think the only situation where this would happen is if the config is set and the ytdlp server is down... which shouldn't happen because the ytdlp server is hosted on the main server

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good to know. Than i feel like the rest of the logic will work fine.

if(web_sound_url)
for(var/mob/M in GLOB.player_list)
var/client/C = M.client
var/this_uid = M.client.UID()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
var/this_uid = M.client.UID()
var/player_uid = M.client.UID()

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be done

@ParadiseSS13-Bot ParadiseSS13-Bot added -Status: Awaiting review This PR is awaiting review from the review team and removed -Status: Awaiting type assignment This PR is waiting for its type to be assigned internally labels Mar 5, 2025
Copy link
Contributor

@Drsmail Drsmail left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe it's Ready for TM

@Drsmail
Copy link
Contributor

Drsmail commented Mar 6, 2025

@warriorstar-orion would you be interested to give this one a look? Feels to me that you probably have necessary expertise.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
-Status: Awaiting review This PR is awaiting review from the review team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants