Answer the question
In order to leave comments, you need to log in
How to access MediaPlayer.Position from timer handler?
There is a piece of the following code:
private System.Timers.Timer updatePosTimer = new System.Timers.Timer(250);
public MediaController() {
mediaPlayer = new MediaPlayer();
updatePosTimer.Elapsed += (object s, ElapsedEventArgs e) => HandleUpdatePosTimer();
}
private void HandleUpdatePosTimer()
{
if (Convert.ToInt32(mediaPlayer.Position.TotalSeconds) != Convert.ToInt32(SongPosition.TotalSeconds))
{
SongPosition = mediaPlayer.Position;
}
}
Answer the question
In order to leave comments, you need to log in
Dispatcher will allow you to execute a piece of code on the UI thread
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question