【发布时间】:2015-08-31 12:10:03
【问题描述】:
我在 Windows Phone 8.0 Silverlight 中开发了一个使用 MediaElement 播放媒体的应用程序。所以,我想在媒体播放期间在 TextBlock 中显示当前位置媒体的时间,怎么办? 谢谢。
【问题讨论】:
标签: windows-phone-8 mediaelement
我在 Windows Phone 8.0 Silverlight 中开发了一个使用 MediaElement 播放媒体的应用程序。所以,我想在媒体播放期间在 TextBlock 中显示当前位置媒体的时间,怎么办? 谢谢。
【问题讨论】:
标签: windows-phone-8 mediaelement
您可以使用 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();
}
【讨论】: