- 爱易网页
-
C#教程
- wpf 播放MP3没声音 请教是什么原因
日期:2014-05-17 浏览次数:20996 次
wpf 播放MP3没声音 请问是什么原因?
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;
namespace MediaPlayTest
{
/// <summary>
/// MainWindow.xaml 的交互逻辑
/// </summary>
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
mediaPlay();
}
//MediaPlayer player = null; 方法一
public void mediaPlay()
{
try
{
MediaPlayer player = new MediaPlayer();
player.Open(new Uri("E:\\我的歌声里.mp3", UriKind.Relative));
VideoDrawing videoDrawing = new VideoDrawing();
videoDrawing.Rect = new Rect(0, 0, 100, 100);
videoDrawing.Player = player;
player.Play();
}
catch (Exception e)
{
throw e;
}
}
bool flag = true;
private void Image_MouseLeftButtonDown_1(object sender, MouseButtonEventArgs e)
{
//player.Play();
//if (flag)
//{
// player.Play();
// flag = false;