■ MediaPlayer 클래스 : 재생시 Slider 연동하기

----------------------------------------------------------------------------------------------------

using System.Windows.Controls;

using System.Windows.Media;

using System.Windows.Threading;

 

private Slider      slider;

private MediaPlayer mediaPlayer;

 

...

 

private DispatcherTimer dispatcherTimer = new DispatcherTimer();

 

...

 

this.DispatcherTimer.Interval = TimeSpan.FromSeconds(1);

 

this.DispatcherTimer.Tick += new EventHandler(dispatcherTimer_Tick);

 

this.DispatcherTimer.Start();

 

...

 

#region 디스패처 타이머 틱 발생시 처리하기 - dispatcherTimer_Tick(sender, e)

 

/// <summary>

/// 디스패처 타이머 틱 발생시 처리하기

/// </summary>

/// <param name="sender">이벤트 발생자</param>

/// <param name="e">이벤트 인자</param>

private static void dispatcherTimer_Tick(object sender, EventArgs e)

{

    this.slider.Value = this.mediaPlayer.Position.TotalSeconds;

}

 

#endregion

----------------------------------------------------------------------------------------------------

Posted by 사용자 icodebroker

댓글을 달아 주세요