Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/vim/5.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
UWP:MediaElement MediaEnded事件不';t火(覆盆子Pi3)_Uwp_Mediaelement_Windowsiot - Fatal编程技术网

UWP:MediaElement MediaEnded事件不';t火(覆盆子Pi3)

UWP:MediaElement MediaEnded事件不';t火(覆盆子Pi3),uwp,mediaelement,windowsiot,Uwp,Mediaelement,Windowsiot,我正在使用Windows IOT Windows.Media.SpeechRecognition和Windows.Media.SpeechSynthesis(通过SRGS文件读取语法文件)在Raspberry Pi3上进行UWP应用程序移植。我正在使用MediaElement通过扬声器播放语音。麦克风和扬声器连接到Raspberry Pi 挑战:合成和识别之间的重叠,即来自说话人的声音被程序识别并进入循环。为了解决这个问题,我将停止识别并在MediaElement.MediaEnded事件结束后

我正在使用Windows IOT Windows.Media.SpeechRecognition和Windows.Media.SpeechSynthesis(通过SRGS文件读取语法文件)在Raspberry Pi3上进行UWP应用程序移植。我正在使用MediaElement通过扬声器播放语音。麦克风和扬声器连接到Raspberry Pi

挑战:合成和识别之间的重叠,即来自说话人的声音被程序识别并进入循环。为了解决这个问题,我将停止识别并在MediaElement.MediaEnded事件结束后启动它。不幸的是,此事件根本没有触发

基于不同的回答,我在这两个版本中都添加了MediaElement

    App.xaml
                <Application.Resources> <MediaElement x:Name="mElement" />   
                </Application.Resources>
    MainPage.xaml
        <Grid x:Name="myGrid" Background="{ThemeResource 
        ApplicationPageBackgroundThemeBrush}">
        <MediaElement x:FieldModifier="Public"  x:Name="mElement" 
        RequestedTheme="Default" MediaEnded="MElement_MediaEnded" 
        CurrentStateChanged="mElement_CurrentStateChanged"/>
        </Grid>

    MainPage.xaml.cs
        private async void MElement_MediaEnded(object sender, 
        Windows.UI.Xaml.RoutedEventArgs e)
        {
             Debug.WriteLine("*******Finally reached Mediaended: **********");
                    //await 
    MyRecognizer.ContinuousRecognitionSession.StartAsync(SpeechContinuousRecognitionMode.PauseOnRecognition);         

         }

private void mElement_CurrentStateChanged(object sender, RoutedEventArgs e)
         {
             MediaElement mediaElement = sender as MediaElement;
             Debug.WriteLine("Media Element Current State : " + 
                mediaElement.CurrentState);
          }
App.xaml


不幸的是,什么都不管用

你用MediaElement玩什么?你是怎么做到的?嗨,丽塔,我正在使用MediaElement向附加到Raspberry Pi的外部扬声器播放文本我没有看到
mElement.SetSource()
mElement.Play()
相关代码。你介意展示完整的代码吗?你玩的时候能听课文吗?