Ejemplo n.º 1
0
        public bool Remove(TTSMessage message)
        {
            if (!_messages.Contains(message))
            {
                return(false);
            }
            if (null == _parentTTS)
            {
                throw new InvalidOperationException("No associated Text-To-Speech subsystem for cancellation");
            }

            _parentTTS.TTSInitialize();

            vx_tts_status status = VivoxCoreInstance.vx_tts_cancel_utterance(_parentTTS.TTSManagerId, message.Key);

            if (TextToSpeech.IsNotTTSError(status))
            {
                BeforeMessageRemoved?.Invoke(this, new ITTSMessageQueueEventArgs(message));
                return(_messages.Remove(message));
            }
            else
            {
                throw new VivoxApiException((int)status);
            }
        }
Ejemplo n.º 2
0
 // Internal. Remove messages from the collection without canceling them.
 // Used during tts subsystem shutdown, or when message playback ends/fails.
 internal void Cleanup(TTSMessage message = null)
 {
     if (null == message)
     {
         foreach (TTSMessage msg in _messages)
         {
             BeforeMessageRemoved?.Invoke(this, new ITTSMessageQueueEventArgs(msg));
         }
         _messages.Clear();
     }
     else if (_messages.Contains(message))
     {
         BeforeMessageRemoved?.Invoke(this, new ITTSMessageQueueEventArgs(message));
         _messages.Remove(message);
     }
 }