Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/310.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 在背景中播放声音_C#_Background - Fatal编程技术网

C# 在背景中播放声音

C# 在背景中播放声音,c#,background,C#,Background,main是参考资料中的MP3…我收到以下错误: *System.Media.SoundPlayer.SoundPlayer(System.IO.Stream)“”的最佳重载方法匹配具有一些无效参数 及 *无法从“byte[]”转换为“System.IO.Stream”请尝试对wav执行此操作 private System.Media.SoundPlayer sp; public Form1() { InitializeComponent();

main是参考资料中的MP3…我收到以下错误: *System.Media.SoundPlayer.SoundPlayer(System.IO.Stream)“”的最佳重载方法匹配具有一些无效参数

*无法从“byte[]”转换为“System.IO.Stream”

请尝试对wav执行此操作

    private System.Media.SoundPlayer sp;
    public Form1()
    {
        InitializeComponent();
        sp = new System.Media.SoundPlayer(Properties.Resources.main);
    }

    private void Form1_Load(object sender, EventArgs e)
    {
        sp.Play();
    }
或者这是MP3:

        System.Media.SoundPlayer player = new System.Media.SoundPlayer();
    player.Stream = Properties.Resources.main;
    player.Play();
试试这个wav

    private System.Media.SoundPlayer sp;
    public Form1()
    {
        InitializeComponent();
        sp = new System.Media.SoundPlayer(Properties.Resources.main);
    }

    private void Form1_Load(object sender, EventArgs e)
    {
        sp.Play();
    }
或者这是MP3:

        System.Media.SoundPlayer player = new System.Media.SoundPlayer();
    player.Stream = Properties.Resources.main;
    player.Play();

微软在这方面做了一个很好的教程

见:


祝你好运。

微软在这方面做了一个很棒的教程

见:


祝你好运。

如果你想在你的网络(C#,Vb.Net)表单中播放一些声音。然后在项目中编写此代码,它将在执行过程中播放声音。请记住,为此,您应该有一个“.wave”文件

WMPLib.WindowsMediaPlayer wplayer = new WMPLib.WindowsMediaPlayer();
wplayer.URL = "main.mp3";
 wplayer.Controls.Play();

如果你想在你的点网络(C#,Vb.Net)形式中播放一些声音。然后在项目中编写此代码,它将在执行过程中播放声音。请记住,为此,您应该有一个“.wave”文件

WMPLib.WindowsMediaPlayer wplayer = new WMPLib.WindowsMediaPlayer();
wplayer.URL = "main.mp3";
 wplayer.Controls.Play();

无法在player.Stream行将类型“byte[]”隐式转换为“System.IO.Stream”,这非常奇怪。你的声音文件是.wav吗?资源中的文件位于何处?uou是否添加了媒体使用?无法在player.Stream行将类型“byte[]”隐式转换为“System.IO.Stream”。这很奇怪。你的声音文件是.wav吗?资源中的文件位于何处?uou是否添加了介质的使用?