1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

How to play sound files on clients

Discussion in 'General Discussion' started by ice cold, Jun 2, 2018.

  1. ice cold
    Offline

    ice cold Plugin Developer Plugin Developer

    Joined:
    Oct 24, 2016
    Messages:
    672
    Likes Received:
    67
    So i'm coding a plugin that should run sounds on clientside

    but for some reason i get this error even when i added the refrence

    Code (Text):
    [RustBuster] [RustBusterPlugin Error] ConsoleMSG Hook: System.IO.FileNotFoundException: Could not load file or assembly 'Interop.WMPLib, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies.
    File name: 'Interop.WMPLib, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'
      at RustBuster2016.API.Hooks.kBU= (System.String msg) [0x00000] in <filename unknown>:0

    CODE

    Code (C#):
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.IO;
    using RustBuster2016;

    namespace TheGameEditionClient
    {
        public class TheGameEditionClientClass : RustBuster2016.API.RustBusterPlugin
        {

            public override string Name { get { return "TheGameEditionClient"; } }
            public override string Author { get { return " by ice cold"; } }
            public override Version Version { get { return new Version("1.0"); } }
            public static TheGameEditionClientClass Instance;

            public override void Initialize()
            {
                Instance = this;
                if(this.IsConnectedToAServer)
                {
                    RustBuster2016.API.Hooks.OnRustBusterClientConsole += CConsole;
                    return;
                }
            }
            public override void DeInitialize()
            {
                RustBuster2016.API.Hooks.OnRustBusterClientConsole -= CConsole;
            }
            public void CConsole(string message)
            {
                if(message == "¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤")
                {
                    if(File.Exists(RustBuster2016.API.Hooks.GameDirectory + "\\RB_Data\\Uberrust\\Sounds\\Spooky.mp3"))
                    {
                        WMPLib.WindowsMediaPlayer wplayer = new WMPLib.WindowsMediaPlayer();
                        wplayer.URL = RustBuster2016.API.Hooks.GameDirectory + "\\RB_Data\\Uberrust\\Sounds\\Spooky.mp3";
                        wplayer.controls.play();
                    }
                }
            }
        }
    }
     
     
    #1
  2. DreTaX
    Offline

    DreTaX Probably knows the answer... Administrator

    Joined:
    Jun 29, 2014
    Messages:
    3,927
    Likes Received:
    705
    You need to place Interop.WMPLib.dll in the managed folder..

    Other than that I hardly think this will have any good outcome.
     
    #2
  3. DreTaX
    Offline

    DreTaX Probably knows the answer... Administrator

    Joined:
    Jun 29, 2014
    Messages:
    3,927
    Likes Received:
    705
    #3
  4. DreTaX
    Offline

    DreTaX Probably knows the answer... Administrator

    Joined:
    Jun 29, 2014
    Messages:
    3,927
    Likes Received:
    705
    I recommend placing your own DLL in your own data folder instead, and select a referencing method from the above link.
     
    #4
  5. ice cold
    Offline

    ice cold Plugin Developer Plugin Developer

    Joined:
    Oct 24, 2016
    Messages:
    672
    Likes Received:
    67
    #5
  6. ice cold
    Offline

    ice cold Plugin Developer Plugin Developer

    Joined:
    Oct 24, 2016
    Messages:
    672
    Likes Received:
    67
    im i also able to run music from url?
     
    #6
  7. McRustReloaded
    Offline

    McRustReloaded Plugin Developer Plugin Developer

    Joined:
    Mar 20, 2016
    Messages:
    149
    Likes Received:
    20
    @ice cold. There is way more possible and with less coding stuff! Your eyes will have multiple orgasms if you see it. I finished the new Small Rad Town. Now there are Sounds and a lot of new stuff, also flying helicopters, animations and a lot more. All of you can see in some hours. I will record a video of my new server "AbsolomRust" with all new possibilities . DreTax and Salva did the best work for legacy and they gave us now the best way to bring back Legacy to life. And we, the team behind AbsolomRust will take this chance! I will proof all in the video later. @salva,dretax and expecialy 4g3v , loveU Guys ;-)
     
    #7
    • Like Like x 1
  8. ice cold
    Offline

    ice cold Plugin Developer Plugin Developer

    Joined:
    Oct 24, 2016
    Messages:
    672
    Likes Received:
    67
    i think this post isnt really related to this topic
     
    #8
  9. DreTaX
    Offline

    DreTaX Probably knows the answer... Administrator

    Joined:
    Jun 29, 2014
    Messages:
    3,927
    Likes Received:
    705
    Have you tried placing the dll in the managed folder?
     
    #9
  10. ice cold
    Offline

    ice cold Plugin Developer Plugin Developer

    Joined:
    Oct 24, 2016
    Messages:
    672
    Likes Received:
    67
    yep still it cant find the refrence
     
    #10
  11. McRustReloaded
    Offline

    McRustReloaded Plugin Developer Plugin Developer

    Joined:
    Mar 20, 2016
    Messages:
    149
    Likes Received:
    20
    Ok Guys ! like i am promised, here is the video !
    Prepare some popcorn and some tissues ;-)



    GreetZ GhosT
     
    #11
  12. Jakkee
    Offline

    Jakkee Plugin Developer Plugin Developer Contributor

    Joined:
    Jul 28, 2014
    Messages:
    1,480
    Likes Received:
    155
    You can’t play MP3, Solved
    Just use online converter to convert to .ogg or .wav
     
    #12
  13. ice cold
    Offline

    ice cold Plugin Developer Plugin Developer

    Joined:
    Oct 24, 2016
    Messages:
    672
    Likes Received:
    67
    Please bro make a seperat thread for this since its not related to this topic + not helping me with my problem
     
    #13
    • Agree Agree x 1
  14. ice cold
    Offline

    ice cold Plugin Developer Plugin Developer

    Joined:
    Oct 24, 2016
    Messages:
    672
    Likes Received:
    67
    Yep already converted but still cant find refrence
     
    #14
  15. Jakkee
    Offline

    Jakkee Plugin Developer Plugin Developer Contributor

    Joined:
    Jul 28, 2014
    Messages:
    1,480
    Likes Received:
    155
    Reference to what?
    It’s all in unity engine
     
    #15
  16. ice cold
    Offline

    ice cold Plugin Developer Plugin Developer

    Joined:
    Oct 24, 2016
    Messages:
    672
    Likes Received:
    67
    Interop.WMPLib.dll

    to use windowsmediaplayer
     
    #16
  17. DreTaX
    Offline

    DreTaX Probably knows the answer... Administrator

    Joined:
    Jun 29, 2014
    Messages:
    3,927
    Likes Received:
    705
    But for what...

    Code (C#):

            public class AudioStorage
            {
                private AudioSource _cclip;
                private GameObject _audioobject;

                public AudioStorage(GameObject obj, AudioSource cli)
                {
                    _audioobject = obj;
                    _cclip = cli;
                }

                public AudioSource AudioClip
                {
                    get { return _cclip; }
                }

                public GameObject AudioObject
                {
                    get { return _audioobject; }
                }
            }
         
            public Dictionary<string, AudioStorage> Sounds = new Dictionary<string, AudioStorage>();

            public void LoadAllSounds()
            {
                string mainpath = RustBuster2016.API.Hooks.GameDirectory;
                string myresourcepath = Path.Combine(mainpath, "\\RB_Data\\MyDir");
                foreach (var x in Directory.GetFiles("*.wav"))
                {
                    string temp = "file:///";
                    temp = temp + x;
                    WWW audioLoader = new WWW(temp);
                    while (!audioLoader.isDone)
                    {
                        // do nothing
                    }
                    GameObject tempgo = new GameObject();
                    AudioSource audio = tempgo.AddComponent<AudioSource>();
                    audio.clip = audioLoader.GetAudioClip(false, false, AudioType.WAV);
                    Sounds[Path.GetFileNameWithoutExtension(x)] = new AudioStorage(tempgo, audio);
                }
            }

            public override void DeInitialize()
            {
                foreach (var x in Sounds.Keys)
                {
                    if (Sounds[x].AudioObject != null)
                    {
                        UnityEngine.Object.Destroy(Sounds[x].AudioObject);
                    }
                }
                Sounds.Clear();
            }
    Then use:

    Code (C#):
    Sounds["xd"].AudioClip.Play();
     
    #17
    • Winner Winner x 1

Share This Page