使用 MediaElement 每播放 10 秒的视频在文本块上显示一个文本

Dispaly a text on textblock in every 10 seconds of video playing using MediaElement

我正在使用 MediaElement 播放视频。为了获得所选视频的总持续时间,我使用了 MediaOpened 事件。现在我想在每 10 秒的视频中显示一段文字。怎么可能?播放视频有什么事件吗?

  <Button Content="Select Video" HorizontalAlignment="Stretch" Click="Button_Click"/>
  <MediaElement Name="videoMediaElement" MediaOpened="videoMediaElement_MediaOpened" />
  <TextBlock x:Name="tb_display_roadname" TextWrapping="Wrap" />

 private async void videoMediaElement_MediaOpened(object sender, RoutedEventArgs e)
    {
        // bool isLive = IsLiveStream(sender as MediaElement);
        var totalDurationTime = videoMediaElement.NaturalDuration.TimeSpan.TotalSeconds;
    }
  private async void Button_Click(object sender, RoutedEventArgs e)
    {
       FileOpenPicker openPicker = new FileOpenPicker();
        foreach (string extension in FileExtensions.Video)
        {
            openPicker.FileTypeFilter.Add(extension);
        }
        file = await openPicker.PickSingleFileAsync();
        // mediaPlayer is a MediaElement defined in XAML
        if (file != null)
        {
            var stream = await file.OpenAsync(Windows.Storage.FileAccessMode.Read);
            videoMediaElement.SetSource(stream, file.ContentType);       
        }

    }

官方 API shows the following available events and I think they are not what you need. You can create a timer 在这里显示或隐藏覆盖媒体元素的文本。