How to play music from a web radio ?

  • For my plugin Radio, I try to play music from a webradio. But I can't get it to work. Can you help?


    Code
    webRadioAsset = SoundAsset.loadFromURL("http://icecast.radiofrance.fr/franceinfo-lofi.mp3");
    sound = player.playSound(webRadioAsset);
  • Thank you. It works. But the music doesn't follow the player and remains localized at the starting point.


    With an mp3, it's possible to simply play a track (without player.getPosition() ) and have that music as background music. Why doesn't it work with webradio?

  • Thank you. It works. But the music doesn't follow the player and remains localized at the starting point.


    With an mp3, it's possible to simply play a track (without player.getPosition() ) and have that music as background music. Why doesn't it work with webradio?

    Afaik the sound is an asset in a 3D space. So it has to "exist" within this 3D space.


    If you create an update loop and then periodically check the position of the player, you can then do a conditional check to see if the player has moved, then if they have moved, move the sound asset to the players new position.

    This will make the sound "follow" the player.

  • further reading threw the API you can assign null for position.

    Code
    sound = player.playSound(webRadioAsset, null);

    position - the world position of the sound. Provide null if you want to play this sound as a 2D sound instead (this means the sound has no actual position and can be heard everywhere).

Participate now!

Don’t have an account yet? Create a new account now and be part of our community!