Check if an audio is content deleted or not?

I am creating a club/dance game and I was wondering how I can detect if an audio is content deleted or not?

A lot of audios that have been removed from the website don’t get their name changed, so I can’t directly compare the audio name with “[ Content Deleted ]”.

I considered setting a sound object’s audio ID to the audio I am trying to check out and wait to see if the sound length ever goes above 0, but I felt like that would add an unnecessary wait between the end of one song and the beginning of another.

Does anyone have any thoughts on this?

4 Likes

You would have to place the audio in the game, and use the “Test” feature in Studio. This would check if anything is playing, or if the audio is inappropriate.

How would I do this? Are you talking about manually testing each audio?
If you are, that is quite inefficient and I would have to preform that on 100s of songs on a regular basis.
Have you any idea how to do this with a script?

If its just that their name is [ Content Deleted ], you could read the name of the audio.

You could use :GetProductInfo(productID).

1 Like

I know how to script the audio, but with patience it would work. You could always just put the audio under Workspace, and turning on “playing”

No.

I’m not sure if there’s any efficient way of doing this. As ArtFoundation said 2 posts ago, you can just do :GetProductInfo(productID) as it is the best method you can use for your use case.

This is not quite what I am looking for. If a sound ID fails to play, I want my script to skip the song.

Use pcall(). For example:

bool = pcall("print('hi')")
if bool == true:
   -- Do something here
elseif bool == false
   -- Do something here

Do you know how edits work?

And when a sound ID fails to load I don’t think it gives an error. Just a message in output.

I in fact, was midway of writing my edit. But I had to go do something. Now I won’t even bother finishing it, probably going to delete my post.

Now to the point, trying doesn’t hurt. In my opinion, it should work. Doesn’t hurt to try, does it. But yeah.

It hurts to try if I have tons to do and I already know it won’t work.

I’m a little late here, but there was a similar post quite long ago. And this seems to be the solution:

Thread link if interested: How to detect if an item ID is Content Deleted? - #10 by joritochip

6 Likes

What exactly are you trying to achieve?

You want to check if the audio doesn’t play it just skips the song?

Edit: You could use something like this?
https://gyazo.com/826e3f8d7e09029e1ba42ceab54faadd

If it doesn’t load, Well then it doesn’t fire?

I feel like that wouldn’t work.
Some songs will take longer to load than others, and by using Sound.Loaded, we may eliminate songs that haven’t yet had a chance to load.

You can make it check every now and then?

If I only check occasionally, then some songs that are Content Deleted and haven’t been tested will play, causing in a breakage of the music system.

@General_Scripter has fixed this issue, I believe

If this isn’t what you’re looking for, Then i would have no clue.

I already tried this method and it did not function properly.

It actually does. It’s sure that if you just copy the code like that, it’s not going to work much. You gotta have to adapt it to your script.

In that case, when MessageOut, I recommend you do checks to make sure the audio is content deleted, and if that’s the case skip the song. When making my music systems, I have a playSong function, that will manage the sound before playing it. It’s really useful if you want to make skipping stuff, like skip commands. When called, you would just have to do playSong()

Here’s a simple script just to show how it would work.

local Workspace = game:GetService("Workspace")
local LogService = game:GetService("LogService")

local Sound = Workspace:WaitForChild("Sound")

local SONG_ARRAY = { 5238436364, 208721394, 1275117701 }
-- 208721394 is content deleted

local songIndex = 0

local function playSong()
	songIndex = songIndex + 1
	if songIndex > #SONG_ARRAY then
		songIndex = 1
	end
	Sound.SoundId = "rbxassetid://" .. SONG_ARRAY[songIndex]
	Sound.TimePosition = 0
	if not Sound.IsLoaded then
		Sound.Loaded:wait()
	end
	Sound:Play()
	Sound.Ended:Connect(playSong)
end

local function onMessageOut(message, messageType)
	if not messageType == Enum.MessageType.MessageError then
		return
	end
	local pattern = "Failed to load sound " .. Sound.SoundId .. ": Unable to download sound data"
	if not string.find(message, pattern, 1, true) then
		return
	end
	print(SONG_ARRAY[songIndex] .. " is content deleted; skipping.")
	playSong()
end

LogService.MessageOut:Connect(onMessageOut)

playSong()

That personally works for me.

8 Likes