Custom Sounds API Confusion?

18.03.2019: Ein neuer Hotfix ( ist nun verfügbar! Multiplayer Server müssen entsprechend geupdated werden

  • Custom Sounds API Confusion?

    Alright, been meaning to try this that I finally want to give it a whirl. Well, that is if it's easy and doesn't require a higher level of scripting. I recall Red51 released an API related thing that you could trigger custom sounds to play that I would love to be able to get some sort of "mechanism" in the game to trigger these sounds that it be neat to have custom music playing. If not physical, then I would at least designate areas in where it would trigger, or so I read you could trigger such. I lost where this was posted, more so with people not really playing around with custom sounds that it's a shame... This is why I'm asking here.

    If anybody has played with these custom sounds then please do chime in because we honestly need to break ground. If you guys won't, then I will. I want to get custom sounds playing that I also want to make someone happy by being able to play the following embedded video in Rising World... Not video wise, just music.

    I have many more things on my end that I would love to get going that I want to build a 'concert hall' in Rising World that it's been an old idea even from Minecraft era. Please tell me that that the 'Custom Sound API' is easy to use..... Also please do tell me so we can get the ball rolling that I hate something so powerful sitting idle. It's like leaving a BMW, Porsche, or similar just sitting in the parking lot all day.......

    Let's get the ball rolling.
    [Threads of Interest - [My Suggestions] "On The List" | [Kitsu Test World ]

    Dieser Beitrag wurde bereits 1 mal editiert, zuletzt von ArcticuKitsu ()

  • Well, that silence isn't reassuring that I can see why it's been sitting idle for so long. Well, I'm finally back home again for 3 days of peace and quiet that I want to break ground for this Custom Sound API thing that I need "some" clarification on it. Now that I have time I did a quick forum search that it lead me to these:…ils/SoundInformation.html…meSound-java.lang.String-

    Sound Support

    From what I'm gathering it can only play the current sounds, yet with a bit of fiddling it 'may' even play external sounds to it. You could add your own sound-effects, and such. That's neat and all, but what I'm looking for is to push this 'Custom Sound API' feature to a more 'Jukebox' state of things similar to how it's done in VRchat. What I want to be able to do is either:

    1) Set up an area where music would play in that determined box area (in a pre-determined area),
    2) Make a jukebox type thing where when you click or hit it that it would play, stop, or go to the next track..... (May need buttons and levers for this one, or an actual jukebox to configure from an .mp3 folder?)

    I fear we may need actual buttons and leavers to make use of custom sounds similar to how StaticModel plugins are done. I'm however yawning up a storm from how exhausted I am from work that tonight may not be the best, but the three following days would be. If you know something please do tell me.

    Please do help me within the three days as I can focus on it the most then.
    [Threads of Interest - [My Suggestions] "On The List" | [Kitsu Test World ]
  • There is indeed support for custom sound files. But it's important to put the sound files on your server, i.e. the game cannot stream audio from a homepage, for example. But just like images or models, the sound files were downloaded automatically.

    Just set up a "SoundInformation" object which is basically a reference to the audio file on your machine. It's recommendable to set up the "SoundInformation" object only once (e.g. in the plugin "onEnable()" function) and reuse it for every player.

    Here is an example plugin which plays a music file (file called "AwesomeMix1.mp3" located in the plugin folder under "music") for all players if someone interacts with a sign which contains the text "Play music":


    1. public class Jukebox extends Plugin implements Listener{
    2. //Our reusable SoundInformation object
    3. SoundInformation soundInfo;
    4. @Override
    5. public void onEnable(){
    6. //Load SoundInformation (only once when plugin is loaded) and reuse it
    7. soundInfo = new SoundInformation(getPath() + "/music/AwesomeMix1.mp3");
    8. //Register EventListener
    9. registerEventListener(this);
    10. }
    11. @Override
    12. public void onDisable(){
    13. //...
    14. }
    15. @EventMethod
    16. public void onObjectInteraction(PlayerObjectInteractionEvent event){
    17. //Check if object is a sign (via object definition)
    18. Definitions.ObjectDefinition def = event.getObjectDefinition();
    19. if(def.isSign()){
    20. //Sign id is stored in "object info", use it to get the actual "Sign"
    21. Sign sign = getWorld().getSign(event.getObjectInfoID());
    22. //Always a good idea to check for null...
    23. if(sign != null){
    24. String text = sign.getText();
    25. //Convert text to lower case (more convenient) and check it
    26. if(text != null && text.toLowerCase().contains("play music")){
    27. //We created a separate method to play/stop our sound (see below)
    28. broadcastSound(event.getObjectPosition());
    29. //Cancel event, so player cannot change the sign text
    30. event.setCancelled(true);
    31. }
    32. }
    33. }
    34. }
    35. //Our custom sound method
    36. public void broadcastSound(Vector3f position){
    37. //We want to play the sound for all players
    38. for(Player player : getServer().getAllPlayers()){
    39. //...but only if the player is still connected
    40. if(player.isConnected()){
    41. //Check if player has soundID attribute
    42. if(player.hasAttribute("soundID")){
    43. //If player has attribute, stop sound
    44. int id = (int) player.getAttribute("soundID");
    45. player.stopSound(id);
    46. //Delete the attribute
    47. player.deleteAttribute("soundID");
    48. }
    49. else{
    50. //Otherwise play new sound (as loop, 0.5f volume, 2-20 min/max dist)
    51. int soundID = player.playSound(soundInfo, true, 0.5f, 1f, 2f, 20f, position);
    52. //Remember to store the sound id as attribute, so we can stop it later
    53. player.setAttribute("soundID", soundID);
    54. }
    55. }
    56. }
    57. }
    58. }
    Alles anzeigen
    If you have any questions, don't hesitate to ask :)

    Dieser Beitrag wurde bereits 1 mal editiert, zuletzt von red51 () aus folgendem Grund: Minor change to the onObjectInteraction() method

  • Well, I have a lot of questions that I still don't know how to use them because someone has to show how it's done for me to tweak and change things. I do thank you for posting that, for showing what goes where, just that I'm still too much of an idiot to make proper use of it. I wouldn't know how to take that to play custom sound that I think I have to bug someone to make me a plugin that I could tweak similar to how you tweak the server files.

    So, you're saying if we hit signs to play them? Awesome. Still recommend buttons and levers, or some "interactive" objects. I can work something out, just need a simplified tutorial to work off of. I never coded something like this.
    [Threads of Interest - [My Suggestions] "On The List" | [Kitsu Test World ]
  • Benutzer online 1

    1 Besucher