Exemplo n.º 1
0
#pragma warning disable CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed

        /// <summary>
        /// Adds an utterance to the utterance queue.
        /// <para>it will be spoken when any other utterances queued before it have been spoken.</para>
        /// </summary>
        public void Speak(SpeechSynthesisUtterance utterance)
        {
            if (Available)
            {
                lock (_EventHandledUtterancesLock)
                {
                    var eventHandledUtterances = _EventHandledUtterances
                                                 .Select(wref => (WeakRef: wref, Utterance: wref.TryGetTarget(out var u) ? u : null))
                                                 .Where(item => item.Utterance != null)
                                                 .ToArray();
                    var eventHandled = eventHandledUtterances.Any(item => Object.ReferenceEquals(item.Utterance, utterance));

                    if (!eventHandled)
                    {
                        eventHandledUtterances = eventHandledUtterances
                                                 .ToArray();
                        _EventHandledUtterances = eventHandledUtterances.Select(item => item.WeakRef)
                                                  .Concat(new[] { new WeakReference <SpeechSynthesisUtterance>(utterance) })
                                                  .ToArray();
                        HandleEvents(utterance);
                    }
                    else
                    {
                        _EventHandledUtterances = eventHandledUtterances.Select(item => item.WeakRef).ToArray();
                    }
                }

                InvokeJavaScriptAsync <object>("speak", this.GetObjectRef(), utterance, utterance.GetObjectRef());
            }
        }
Exemplo n.º 2
0
 /// <summary>
 /// Adds an utterance to the utterance queue.
 /// <para>it will be spoken when any other utterances queued before it have been spoken.</para>
 /// </summary>
 public void Speak(SpeechSynthesisUtterance utterance)
 {
     if (Available)
     {
         JSRuntime.InvokeAsync <object>(Namespace + ".speak", this.GetObjectRef(), utterance, utterance.GetObjectRef());
     }
 }
Exemplo n.º 3
0
#pragma warning disable CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed

        /// <summary>
        /// Adds an utterance to the utterance queue.
        /// <para>it will be spoken when any other utterances queued before it have been spoken.</para>
        /// </summary>
        public void Speak(SpeechSynthesisUtterance utterance)
        {
            if (Available)
            {
                InvokeJavaScriptAsync <object>("speak", this.GetObjectRef(), utterance, utterance.GetObjectRef());
            }
        }