WPF C# Tutorial

    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="CodePlayback" Height="300" Width="300"
    xmlns:local="clr-namespace:SoundAndVideo">
  
    
  

          
      
      Play
      Stop
      Pause      
      Volume:
      
      Balance: 
      
      Speed: 
      
      Seek To: 
                     ValueChanged="sliderPosition_ValueChanged">
      
  

//File:Window.xaml.cs
using System;
using System.Collections.Generic;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using System.Windows.Media.Animation;
using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Data;
namespace SoundAndVideo
{
    public partial class CodePlayback : System.Windows.Window
    {
        public CodePlayback()
        {
            InitializeComponent();
        }
        private void sliderSpeed_ValueChanged(object sender, RoutedEventArgs e)
        {
             media.SpeedRatio = ((Slider)sender).Value;
        }
        private void cmdPlay_Click(object sender, RoutedEventArgs e)
        {
            media.Play();
        }
        private void cmdPause_Click(object sender, RoutedEventArgs e)
        {
            media.Pause();
        }
        private void cmdStop_Click(object sender, RoutedEventArgs e)
        {            
            media.Stop();
            media.SpeedRatio = 1;
        }
        private void media_MediaOpened(object sender, RoutedEventArgs e)
        {
            sliderPosition.Maximum = media.NaturalDuration.TimeSpan.TotalSeconds;
        }
        private void sliderPosition_ValueChanged(object sender, RoutedEventArgs e)
        {
            media.Pause();
            media.Position = TimeSpan.FromSeconds(sliderPosition.Value);
            media.Play();
        }
    }
    public class TimeSpanConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter,System.Globalization.CultureInfo culture)
        {
            try
            {
                TimeSpan time = (TimeSpan)value;
                return time.TotalSeconds;
            }
            catch
            {
                return 0;
            }
        }
        public object ConvertBack(object value, Type targetType, object parameter,System.Globalization.CultureInfo culture)
        {
            double seconds = (double)value;
            return TimeSpan.FromSeconds(seconds);
        }
    }
}