示例#1
0
        /// <summary>
        /// Play a prerecorded sound
        /// </summary>
        /// <param name="filename">Name of the file to play</param>
        /// <param name="sps">Samples per second</param>
        /// <param name="worldPos">Position of the sound</param>
        /// <param name="deleteAfter">True if we should delete the file when done</param>
        /// <param name="global">True if position is in world coordinates
        /// instead of hed-relative</param>
        internal override void Play(string filename,
                                    int sps,
                                    OpenMetaverse.Vector3 worldPos,
                                    bool deleteAfter,
                                    bool global)
        {
            if (speechPlayer != null)
            {
                // Play this file at the designated position.  When it finishes, the
                // SpeechDoneHandler will be called.
                uint len = speechPlayer.Play(filename, global, worldPos);

                // Wait for it to finish. Max 2sec longer tha it is supposed to
                playing.WaitOne((int)len + 2000, false);
            }

            // Delete the WAV file if requested.
            if (deleteAfter)
            {
                File.Delete(filename);
            }
        }