示例#1
0
        public void PlayVoiceLine(string voice, uint hash, Action onEnd)
        {
            var      path = data.GetVoicePath(voice);
            VoiceUtf v;

            if (!voiceUtfs.TryGetValue(path, out v))
            {
                v = new VoiceUtf(path);
                voiceUtfs.Add(path, v);
            }
            var file = v.AudioFiles[hash];
            var sn   = audio.AllocateData();

            sn.LoadStream(new MemoryStream(file));
            audio.PlaySound(sn, false, 1, -1, -1, null, sn, onEnd);
        }
示例#2
0
 public void PlayVoiceLine(string voice, uint hash, Action onEnd)
 {
     Task.Run(() =>
     {
         var path     = data.GetVoicePath(voice);
         var v        = voiceUtfs.GetOrAdd(path, (s) => new VoiceUtf(s));
         var file     = v.AudioFiles[hash];
         var sn       = audio.AllocateData();
         using var ms = new MemoryStream(file);
         sn.LoadStream(ms);
         ui.QueueUIThread(() =>
         {
             var instance           = audio.CreateInstance(sn, SoundType.Voice);
             instance.DisposeOnStop = true;
             instance.OnStop        = () => {
                 sn.Dispose();
                 onEnd?.Invoke();
             };
             instance.Play();
         });
     });
 }
示例#3
0
        public void PlayVoiceLine(string voice, uint hash, Action onEnd)
        {
            //TODO: Make this asynchronous
            var      path = data.GetVoicePath(voice);
            VoiceUtf v;

            if (!voiceUtfs.TryGetValue(path, out v))
            {
                v = new VoiceUtf(path);
                voiceUtfs.Add(path, v);
            }
            var file = v.AudioFiles[hash];
            var sn   = audio.AllocateData();

            sn.LoadStream(new MemoryStream(file));
            var instance = audio.CreateInstance(sn, SoundType.Voice);

            instance.DisposeOnStop = true;
            instance.OnStop        = () => {
                sn.Dispose();
                onEnd();
            };
            instance.Play();
        }