代码页面:
using System;
using System.Collections.Generic;
using System.Linq;
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.Navigation;
using System.Windows.Shapes;
using System.Threading;
using System.Windows.Threading;
namespace RandomDome
{
/// <summary>
/// MainWindow.xaml 的交互逻辑
/// </summary>
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
}
int i = 1;
int j = 9;
DispatcherTimer dt = new DispatcherTimer();
MediaPlayer player = new MediaPlayer();
private void btnBegin_Click(object sender, RoutedEventArgs e)
{
string mp = Environment.CurrentDirectory;
int a = mp.LastIndexOf('\\');
int b = a - 3;
mp = mp.Substring(0, b);
mp = mp + "\\music\\那一夜.mp3";
player.Open(new Uri(mp, UriKind.RelativeOrAbsolute ));
player.Play();
dt.Interval = TimeSpan.FromMilliseconds(10);
dt.Tick += new EventHandler(dt_Tick);
dt.Start();