【问题标题】:Dispaly time current position media in TextBlock - Windows Phone 8.0 Silverlight在 TextBlock 中显示时间当前位置媒体 - Windows Phone 8.0 Silverlight
【发布时间】:2015-08-31 12:10:03
【问题描述】:

我在 Windows Phone 8.0 Silverlight 中开发了一个使用 MediaElement 播放媒体的应用程序。所以,我想在媒体播放期间在 TextBlock 中显示当前位置媒体的时间,怎么办? 谢谢。

【问题讨论】:

    标签: windows-phone-8 mediaelement


    【解决方案1】:

    您可以使用 DispatcherTimer 来更新文本块。像这样:

    DispatcherTimer timer = new DispatcherTimer();
    timer.Interval = new TimeSpan(0, 0, 1);
    timer.Tick += timer_Tick;
    timer.Start();
    

    要获取当前位置,在timer_Tick函数中,使用yourPlayer.Position.ToString()

    void timer_Tick(object sender, EventArgs e)
        {
            textBlock.Text = yourPlayer.Position.ToString();
        }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-10-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-01-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多