protected override void OnContentChanged(object oldContent, object newContent) { base.OnContentChanged(oldContent, newContent); if (_mediaPlayer != null) { if (newContent is string) { string pathName = newContent as string; switch (BasicMediaPlayer.GetMediaType(pathName)) { case BasicMediaPlayer.MediaType.mtUnknown: IsMedia = false; break; default: IsMedia = true; _mediaPlayer.Source = new Uri(pathName); break; } } else { _mediaPlayer.Source = null; } } }
public static void OnMediaPositionChanged(object sender, DependencyPropertyChangedEventArgs args) { BasicMediaPlayer prev = (BasicMediaPlayer)sender; TimeSpan ts = (TimeSpan)args.NewValue; if (Math.Abs(ts.Subtract(prev.mediaElement.Position).TotalMilliseconds) > 1000) { prev.mediaElement.Position = ts; } }
public static void OnCurrentMediaTypeChanged(object sender, DependencyPropertyChangedEventArgs args) { BasicMediaPlayer prev = (BasicMediaPlayer)sender; if (prev.mmSlider != null) { MediaType mtype = (MediaType)args.NewValue; if (mtype == MediaType.mtVideo || mtype == MediaType.mtAudio) { prev.mmSlider.Visibility = Visibility.Visible; } else { prev.mmSlider.Visibility = Visibility.Collapsed; } } }
public static void OnSourceChanged(object sender, DependencyPropertyChangedEventArgs args) { BasicMediaPlayer prev = (BasicMediaPlayer)sender; prev.Load(args.NewValue as Uri); }