diff -r 644464191714 -r 9e222810f5b5 src/FingersDance.Control.Player/UserControlPlayer.xaml.cs --- a/src/FingersDance.Control.Player/UserControlPlayer.xaml.cs Fri Aug 07 01:03:14 2009 +0200 +++ b/src/FingersDance.Control.Player/UserControlPlayer.xaml.cs Sun Aug 09 18:29:41 2009 +0200 @@ -14,29 +14,72 @@ { public partial class UserControlPlayer { + #region Variables + private bool isPlaying = false; + #endregion - private bool play; + public event EventHandler PlayerOpened; public UserControlPlayer() { this.InitializeComponent(); - initPlayer(); - } + } + #region Properties + public double TotalMilliseconds + { + get + { + return MediaElementVideo.NaturalDuration.TimeSpan.TotalMilliseconds; + } + } + public MediaElement Player + { + get + { + return MediaElementVideo; + } + set + { + MediaElementVideo= value; + } + } + + #endregion + + + #region Methodes void initPlayer() - { + { //init player - play = false; + isPlaying = false; MediaElementVideo.Source = new Uri("Resources\\Lake.wmv", UriKind.Relative); MediaElementVideo.LoadedBehavior = MediaState.Manual; + MediaElementVideo.UnloadedBehavior = MediaState.Manual; + MediaElementVideo.ScrubbingEnabled= true; } + public void playerPause() + { + MediaElementVideo.Pause(); + } + public void playerPlay() + { + MediaElementVideo.Play(); + } + public void playerStop() + { + MediaElementVideo.Stop(); + } + + #endregion + private void ButtonPlayPause_ContactDown(object sender, Microsoft.Surface.Presentation.ContactEventArgs e) { - if (!play)//Play + if (!isPlaying)//Play { - play = true; + isPlaying = true; try { MediaElementVideo.Play(); @@ -45,38 +88,87 @@ } else//Pause { - play = false; + isPlaying = false; try { MediaElementVideo.Pause(); } - catch (Exception exx ) { } + catch (Exception exx) { } } } private void ButtonPlayPause_Click(object sender, RoutedEventArgs e) { - if (!play)//Play + if (!isPlaying)//Play { - play = true; + isPlaying = true; try { MediaElementVideo.Play(); } - catch (Exception ex ) { } - ButtonPlayPause.Background = FindResource("[Skin_1]_Pause_button_xaml") as Brush; + catch (Exception ex) { } + } else//Pause { - play = false; + isPlaying = false; try { MediaElementVideo.Pause(); } - catch (Exception exx ) { } - ButtonPlayPause.Background = FindResource("[Skin_1]_Play_button_xaml") as Brush; + catch (Exception exx) { } + //ButtonPlayPause.Background = FindResource("[Skin_1]_Play_button_xaml") as Brush; + } + } + + private void ButtonFastForward_Click(object sender, RoutedEventArgs e) + { + if (MediaElementVideo.SpeedRatio <= 3) + MediaElementVideo.SpeedRatio += 1; + } + + private void ButtonFastForward_ContactDown(object sender, Microsoft.Surface.Presentation.ContactEventArgs e) + { + if (MediaElementVideo.SpeedRatio <= 3) + MediaElementVideo.SpeedRatio += 1; + } + + private void ButtonRewind_Click(object sender, RoutedEventArgs e) + { + //TimeSpan ts = new TimeSpan(0, 0, 0, 0); + if (MediaElementVideo.SpeedRatio > 1) + { + MediaElementVideo.SpeedRatio -= 1; } + else + { + MediaElementVideo.Position = MediaElementVideo.Position.Add(new TimeSpan(0, 0, 0, -5)); + } + } + + private void ButtonRewind_ContactDown(object sender, Microsoft.Surface.Presentation.ContactEventArgs e) + { + + //TimeSpan ts = new TimeSpan(0, 0, 0,0); + if (MediaElementVideo.SpeedRatio > 1) + { + MediaElementVideo.SpeedRatio -= 1; + } + else + { + MediaElementVideo.Position = MediaElementVideo.Position.Add(new TimeSpan(0, 0, 0, -5)); + } + } + + private void MediaElementVideo_MediaOpened(object sender, RoutedEventArgs e) + { + OnPlayerOpened(); + } + protected virtual void OnPlayerOpened() + { + if(PlayerOpened!=null) + PlayerOpened(this, new EventArgs()); } } } \ No newline at end of file