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.
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?
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.
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.
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()