コード例 #1
0
        private void addMusic(string path, MusicItem music)
        {
            Monitor.Log("Loading " + music.File + " ...", LogLevel.Info);

            SoundEffect soundEffect = null;

            string orgPath = path;

            path = config.Convert ? path.Replace(".ogg", ".wav") : path;

            if (config.Convert && !File.Exists(path))
            {
                Convert(orgPath);
            }

            if (path.EndsWith(".wav"))
            {
                soundEffect = SoundEffect.FromStream(new FileStream(path, FileMode.Open));
            }
            else
            {
                soundEffect = OggLoader.Load(path);
            }

            Monitor.Log(music.File + " Loaded", LogLevel.Trace);
            string[] ids = music.Id.Split(',').Select(p => p.Trim()).ToArray();
            foreach (string id in ids)
            {
                Music.Add(new StoredMusic(id, soundEffect, music.Ambient, music.Loop, music.Conditions));
            }
        }
コード例 #2
0
        private void addMusic(string path, MusicItem music)
        {
            Monitor.Log("Loading " + music.File + " ...", LogLevel.Info);
            SoundEffect soundEffect = OggLoader.Load(path);

            Monitor.Log(music.File + " Loaded", LogLevel.Trace);
            string[] ids = music.Id.Split(',').Select(p => p.Trim()).ToArray();
            foreach (string id in ids)
            {
                Music.Add(new StoredMusic(id, soundEffect, music.Ambient, music.Loop, music.Conditions));
            }
        }
コード例 #3
0
        private void addMusic(string path, MusicItem music)
        {
            Monitor.Log("Loading " + music.File + " ...", LogLevel.Info);
            string oPath = path;

            string orgPath = path;

            SoundEffect soundEffect = LoadSoundEffect(path);

            if (soundEffect != null)
            {
                Monitor.Log(music.File + " Loaded", LogLevel.Trace);
                string[] ids = music.Id.Split(',').Select(p => p.Trim()).ToArray();
                foreach (string id in ids)
                {
                    Music.Add(new StoredMusic(id, music.Preload ? soundEffect : null, music.Ambient, music.Loop, music.Conditions, path));
                }
            }
            else
            {
                Monitor.Log(music.File + " failed to load", LogLevel.Warn);
            }
        }
コード例 #4
0
        private void addMusic(string path, MusicItem music)
        {
            Monitor.Log("Loading " + music.File + " ...", LogLevel.Info);
            string oPath = path;

            string orgPath = path;

            path = config.Convert ? path.Replace(".ogg", ".wav") : path;
            bool done = false;
            int  cc   = 0;

            if (config.Convert)
            {
                while (!done && cc < ti)
                {
                    if (File.Exists(path))
                    {
                        FileStream file = File.Open(path, FileMode.Open);
                        try
                        {
                            if (file.Length < 100)
                            {
                                file.Close();
                                file.Dispose();
                                File.Delete(path);
                                Convert(orgPath);
                            }
                            else
                            {
                                file.Close();
                                file.Dispose();
                            }
                        }
                        catch
                        {
                            cc++;
                            file.Close();
                            file.Dispose();
                            Thread.Sleep(slp);
                        }
                    }
                    else
                    {
                        Convert(orgPath);
                    }
                    done = true;
                }
            }

            SoundEffect soundEffect = LoadSoundEffect(path);

            if (soundEffect != null)
            {
                Monitor.Log(music.File + " Loaded", LogLevel.Trace);
                string[] ids = music.Id.Split(',').Select(p => p.Trim()).ToArray();
                foreach (string id in ids)
                {
                    Music.Add(new StoredMusic(id, music.Preload ? soundEffect :null, music.Ambient, music.Loop, music.Conditions, path));
                }
            }
            else
            {
                Monitor.Log(music.File + " failed to load", LogLevel.Warn);
                //Monitor.Log(path + ":" +le.Message + ":" + le.StackTrace, LogLevel.Trace);
            }

            loads--;
            simLoad--;
            working.Remove(oPath);
        }