Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/google-app-engine/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Windows phone 8.1 如何获取语音合成器流的持续时间_Windows Phone 8.1_Mediaelement_Duration_Speechsynthesizer - Fatal编程技术网

Windows phone 8.1 如何获取语音合成器流的持续时间

Windows phone 8.1 如何获取语音合成器流的持续时间,windows-phone-8.1,mediaelement,duration,speechsynthesizer,Windows Phone 8.1,Mediaelement,Duration,Speechsynthesizer,在播放SpeechSynthesisterStream之前,我如何测量它的持续时间 SpeechSynthesizer ss = new SpeechSynthesizer(); SpeechSynthesisStream sss; ss.Voice = SpeechSynthesizer.AllVoices[3]; sss = await ss.SynthesizeTextToStreamAsync("Hello world."); Media

在播放SpeechSynthesisterStream之前,我如何测量它的持续时间

     SpeechSynthesizer ss = new SpeechSynthesizer();
     SpeechSynthesisStream sss;
     ss.Voice = SpeechSynthesizer.AllVoices[3];
     sss = await ss.SynthesizeTextToStreamAsync("Hello world.");
     MediaElement mediaElement = new MediaElement();
     mediaElement.SetSource(sss, sss.ContentType);

     //here I want to get the duration

     mediaElement.Play();

这段代码工作得很好,可以说“Hello world”。一段时间后,mediaElement.NaturalDuration也具有正确的值。但我需要在播放演讲之前尽快知道演讲的持续时间。我为mediaElement.MediaOpen添加了处理程序,但此“SetSource”可能不会触发此事件。谢谢。

要启动
MediaOpen
,您需要将
MediaElement
连接到可视树。将MediaElement附加到可视化树后,
MediaOpen
事件中应提供
NaturalDuration

要启动
MediaOpen
,需要将
MediaElement
附加到可视化树。将MediaElement附加到可视化树后,
MediaOpen
事件中应提供
NaturalDuration

在何处将
MediaElement
附加到可视化树?MediaOpen在连接到可视化树之前不会启动,并且在
MediaOpen
事件中应该可以使用
NaturalDuration
。在我将mediaElement连接到可视化树后,MediaOpen事件开始工作。谢谢您的帮助。不客气-我添加了它作为答案:)您将
MediaElement
附加到可视化树的什么位置?MediaOpen在连接到可视化树之前不会启动,并且在
MediaOpen
事件中应该可以使用
NaturalDuration
。在我将mediaElement连接到可视化树后,MediaOpen事件开始工作。谢谢你的帮助。不客气-我已经添加了它作为回答:)