标签:
private ContentControl cc = null;
private void muiscPlay(object sender, RoutedEventArgs e)
        {
            string name = ((ContentControl)sender).Tag.ToString();
            if (string.IsNullOrWhiteSpace(name))
                return;
            if (filename != name)
            {
                player.Stop();
                isStart = true;
                if (cc != null)
                    cc.SetResourceReference(System.Windows.Controls.Button.StyleProperty, "playButtonStyle2");
                player.LoadedBehavior = MediaState.Manual;
                player.Source = new Uri("./Resource/musics/" + name, UriKind.Relative);
                filename = name;
            }
            if (isStart)
            {
                player.Play();
                ((ContentControl)sender).SetResourceReference(System.Windows.Controls.Button.StyleProperty, "pauseButtonStyle2");
                cc = ((ContentControl)sender);
                isStart = false;
            }
            else
            {
                player.Pause();
                ((ContentControl)sender).SetResourceReference(System.Windows.Controls.Button.StyleProperty, "playButtonStyle2");
                isStart = true;
            }
        }
标签:
原文地址:http://www.cnblogs.com/DataBase-123/p/5783304.html