Newer
Older
Correlator / Correlator / Pages / AudioFileUserControl.xaml.cs
using System.Media;
using System.Windows;
using System.Windows.Controls;

namespace Correlator.Pages
{
    /// <summary>
    /// AudioFileUserControl.xaml 的交互逻辑
    /// </summary>
    public partial class AudioFileUserControl : UserControl
    {
        private readonly SoundPlayer _soundPlayer = new SoundPlayer();

        public AudioFileUserControl()
        {
            InitializeComponent();
        }

        private void PlayAudioButton_OnClick(object sender, RoutedEventArgs e)
        {
            var fullPath = (sender as Button)?.Tag.ToString();

            _soundPlayer.SoundLocation = fullPath;
            _soundPlayer.Play();
        }
    }
}