game.playSound() function not working

Hi, I am creating something that would trig sound, and the function game.playSound() works well for me until last week. However, I don’t know why it cannot work now.

I usually use it with mp3 file in google drive, and I also test make an internal sound (like this: https://cdn.gather.town/storage.googleapis.com/gather-town.appspot.com/internal-dashboard/sounds/BuHpL3aHEyvdbC9bhxsAA) as the url src parameter, but also I cannot hear any voice.

Does anyone know how to solve it? thanks a lot!

sorry, this is a bug and we’re looking into it!

Oh sorry to hear that… thanks for your reply!!!

Hi @npfoss! We noticed this as well, and are looking forward to the fix. Thank you!

Hello, we have identified and fixed a client issue (it will generally require a reload to apply), thanks for reporting this and sorry for the trouble!

1 Like

Hi @gianluca and @npfoss,

I was just trying to use game.playSound again, but I’m getting this error. I think it might be related to a CORS problem. If that is the issue, is there a way to upload the sound file to the Gather CDN like we do for images?

Error fetching audio source: [my wav file]
console.error @ bundle.f05577fc3e2977db5599.js:404

Thanks!
Kevin

Hey @Kevin-RtR, CORS is handled by the server that hosts these files, so your host.

You should be able to play sounds from any host that has CORS enabled

game.playSound(“https://assets.mixkit.co/sfx/preview/mixkit-fast-small-sweep-transition-166.mp3”, 1, game.engine.clientUid);

Hi @gianluca, ah ok perfect!

I updated my bucket with a CORS policy, and it seems to be working now.

Just out of curiosity, was requiring a CORS policy added in the latest update on the client-side? I know we used to use this same S3 bucket before without a CORS policy, and we never had an issue previously.

It wasn’t with the latest update but a recent one. We did this to improve performance (caching).

Is there any documentation on this? I know a number of the Ambassadors were dealing with sound issues a week or so ago, and that may have been the issue.

1 Like

Hi,

im having this issue too.

Im using AzuraCast Internetradio, which is running on Digital Ocean according to AzuraCast Support it should already use

access-control-allow-headers: Origin, Accept, X-Requested-With, Content-Type, Icy-MetaData
access-control-allow-methods: GET, OPTIONS, SOURCE, PUT, HEAD, STATS
access-control-allow-origin: *

However Gather.Town is returning a “Failed to Fetch” Error,

Ive checked if I can edit something in DigitalOcean, but the Projekt there doesnt have any relateable Options. Ive found some Options for Apps and Spaces at DigitalOcean, but thats not the type of the AzuraCast Application Im using…

Can anyone please help to find clarification on where the problem is burried?

This looks like a use case we internally don’t support so the recent changes didn’t cover (but the previous implementation would allow to). It should be easy to restore it, by adding an additional flag for “streams”, do you currently use this with the game.playSound API?

1 Like

Thank you for considering to restore it. I use it as sound objects, by replacing the original sound src with the “https://radio.url.mp3” string

So it looked like that

id: "Radio",

x: 27,

y: 12,

    normal: "https://cdn.gather.town/v0/b/gather-town.appspot.com/o/internal-dashboard-upload%2FPGcG9m2GSI8BCixU?alt=media&token=1890032a-0726-40db-a8bb-9426871e7db8",

sound: {

       src: "https://my-radio-url.....radio.mp3",

  volume: 1.0,

  maxDistance: 30,

  loop: true, 

},

type: 0,

width: 1, 

height: 1,

Restoring it for sound objects might require some additional work, can’t give any ETA yet

if game.playSound() is easier and quicker for you, I can use this for now to provide sound for the upcoming Christmas parties :smiley:

This has been restored for sound objects (will require a client refresh) but it’s now enabled with the additional stream property

1 Like

Thanks for the update. Could you expand on what these options actually do? Specifically the isPositional and stream. Documenting changes in the functionality will help as the sound features change in the next quarter (per Liz on Slack).

You can ignore all the other properties as they already existed and are not required for this use case. stream is now being added to support range requests.

It looks like still not working. :frowning_face:

I’m trying with sound URLs with CORS enabled. Form my server and from examples in this thread.
fetch(sound).then(res=>console.log(res.statusText)) prints OK in the browser console.

I did try OGG and MP3 files, and also played it in the browser to ensure that works.

I did try the examples bellow on Chrome and Firefox:

game.playSound(sound, 1, game.engine.clientUid) 
game.playSound(sound, 1) 
game.sendAction({
    $case: "playSound",
    playSound: {
      src: sound,
      volume: 1,
      targetId: game.engine.clientUid
    },
  })

I also try to discover the problem with

game.subscribeToEvent("ErrorEvent", (data, context) => {
    console.log('ERROR!!!', data, context)
})

…but that was not triggered.

Do you see any errors in the console when you call the playSound action?