有人用过System.Windows.Media命名空间中的MediaPlayer类的吗,在XP上怎么不能播放音频

时间:2022-11-23 09:08:11
如题,在WIn7 32位、64位都没有问题,这些系统我在虚拟机上都装了,唯独XP的不能像想象中的可以播放音频,求解答

6 个解决方案

#1


无厘头的问题,谁知道你代码怎么写的。 有人用过System.Windows.Media命名空间中的MediaPlayer类的吗,在XP上怎么不能播放音频

#2


C# 是基于.net环境的语言,所以无论你用什么软件开发,在什么操作系统下运行 是没有直接关系,只与你的开发环境(比如.Net Framework2.0,3.0,3.5,4,4.5 )和相应的运行环境有关,也就是说你开发的环境如果是VS 2012 就是.Net Framework 4.5 那么你运行的环境必须是高于这个版本的,才能正常运行。


看你的版本是多少?xp上有没有安装.NetFramework相应的版本。

#3


引用 2 楼 zyl_leilei 的回复:
C# 是基于.net环境的语言,所以无论你用什么软件开发,在什么操作系统下运行 是没有直接关系,只与你的开发环境(比如.Net Framework2.0,3.0,3.5,4,4.5 )和相应的运行环境有关,也就是说你开发的环境如果是VS 2012 就是.Net Framework 4.5 那么你运行的环境必须是高于这个版本的,才能正常运行。


看你的版本是多少?xp上有没有安装.NetFramework相应的版本。


谢谢回复,我装了.Net Framework 4.0,我用的是VS2012,在编译设置中选择的目标框架就是.Net Framework 4.0

#4


我的代码



using System.Windows;
using System.Windows.Media;
namespace Test
{
    public partial class Form1 : Form
    {
        MediaPlayer play = new MediaPlayer();
        public Form1()
        {
            InitializeComponent();
        }

        private void btnMedia_Click(object sender, EventArgs e)
        {
            string strPath = System.Environment.CurrentDirectory;
            string strFile = strPath + "\\hello.mp3";
            play.Open(new Uri(strFile, UriKind.Relative));
            play.Play();
        }
}



#5


引用 4 楼 zcnc2012 的回复:
我的代码



using System.Windows;
using System.Windows.Media;
namespace Test
{
    public partial class Form1 : Form
    {
        MediaPlayer play = new MediaPlayer();
        public Form1()
        {
            InitializeComponent();
        }

        private void btnMedia_Click(object sender, EventArgs e)
        {
            string strPath = System.Environment.CurrentDirectory;
            string strFile = strPath + "\\hello.mp3";
            play.Open(new Uri(strFile, UriKind.Relative));
            play.Play();
        }
}

很有可能是路径问题,试试Application.StartupPath + @"\hello.mp3"??

#6


引用 5 楼 zyl_leilei 的回复:
Quote: 引用 4 楼 zcnc2012 的回复:

我的代码



using System.Windows;
using System.Windows.Media;
namespace Test
{
    public partial class Form1 : Form
    {
        MediaPlayer play = new MediaPlayer();
        public Form1()
        {
            InitializeComponent();
        }

        private void btnMedia_Click(object sender, EventArgs e)
        {
            string strPath = System.Environment.CurrentDirectory;
            string strFile = strPath + "\\hello.mp3";
            play.Open(new Uri(strFile, UriKind.Relative));
            play.Play();
        }
}

很有可能是路径问题,试试Application.StartupPath + @"\hello.mp3"??


试了下,没有用,放在Win7 32位/64位都可以

#1


无厘头的问题,谁知道你代码怎么写的。 有人用过System.Windows.Media命名空间中的MediaPlayer类的吗,在XP上怎么不能播放音频

#2


C# 是基于.net环境的语言,所以无论你用什么软件开发,在什么操作系统下运行 是没有直接关系,只与你的开发环境(比如.Net Framework2.0,3.0,3.5,4,4.5 )和相应的运行环境有关,也就是说你开发的环境如果是VS 2012 就是.Net Framework 4.5 那么你运行的环境必须是高于这个版本的,才能正常运行。


看你的版本是多少?xp上有没有安装.NetFramework相应的版本。

#3


引用 2 楼 zyl_leilei 的回复:
C# 是基于.net环境的语言,所以无论你用什么软件开发,在什么操作系统下运行 是没有直接关系,只与你的开发环境(比如.Net Framework2.0,3.0,3.5,4,4.5 )和相应的运行环境有关,也就是说你开发的环境如果是VS 2012 就是.Net Framework 4.5 那么你运行的环境必须是高于这个版本的,才能正常运行。


看你的版本是多少?xp上有没有安装.NetFramework相应的版本。


谢谢回复,我装了.Net Framework 4.0,我用的是VS2012,在编译设置中选择的目标框架就是.Net Framework 4.0

#4


我的代码



using System.Windows;
using System.Windows.Media;
namespace Test
{
    public partial class Form1 : Form
    {
        MediaPlayer play = new MediaPlayer();
        public Form1()
        {
            InitializeComponent();
        }

        private void btnMedia_Click(object sender, EventArgs e)
        {
            string strPath = System.Environment.CurrentDirectory;
            string strFile = strPath + "\\hello.mp3";
            play.Open(new Uri(strFile, UriKind.Relative));
            play.Play();
        }
}



#5


引用 4 楼 zcnc2012 的回复:
我的代码



using System.Windows;
using System.Windows.Media;
namespace Test
{
    public partial class Form1 : Form
    {
        MediaPlayer play = new MediaPlayer();
        public Form1()
        {
            InitializeComponent();
        }

        private void btnMedia_Click(object sender, EventArgs e)
        {
            string strPath = System.Environment.CurrentDirectory;
            string strFile = strPath + "\\hello.mp3";
            play.Open(new Uri(strFile, UriKind.Relative));
            play.Play();
        }
}

很有可能是路径问题,试试Application.StartupPath + @"\hello.mp3"??

#6


引用 5 楼 zyl_leilei 的回复:
Quote: 引用 4 楼 zcnc2012 的回复:

我的代码



using System.Windows;
using System.Windows.Media;
namespace Test
{
    public partial class Form1 : Form
    {
        MediaPlayer play = new MediaPlayer();
        public Form1()
        {
            InitializeComponent();
        }

        private void btnMedia_Click(object sender, EventArgs e)
        {
            string strPath = System.Environment.CurrentDirectory;
            string strFile = strPath + "\\hello.mp3";
            play.Open(new Uri(strFile, UriKind.Relative));
            play.Play();
        }
}

很有可能是路径问题,试试Application.StartupPath + @"\hello.mp3"??


试了下,没有用,放在Win7 32位/64位都可以