问题描述
我想播放声音文件以在控制台应用程序中播放,但是以下操作不起作用:
I want to play a sound file to play in my console application but the following doesn't work:
My.Computer.Audio.Play("[文件路径字符串]",AudioPlayMode.Background)
将鼠标悬停在我的电脑"上时,它带来了错误'Computer'不是'JapaneseHelper.My'
的成员.当悬停在Audio.PlayMode上时,它说未声明'AudioPlayMode'.由于其保护级别,它可能无法访问.
When hovering over "my computer" it brings brings up the error 'Computer' is not a member of 'JapaneseHelper.My'
. And when hovering over Audio.PlayMode it says 'AudioPlayMode' is not declared. It may be inaccessible due to its protection level.
我到处都在搜索此内容,但是找不到任何可以显示该操作方法的信息,我只看到了有关表单应用程序的说明(当我尝试复制在表单应用程序中所做的操作时,它不会要么工作).我已经尝试了几次导入"例如 Import System.IO
,但他们没有解决此问题.我不想打开音乐播放器,而是希望像 My.Computer.Audio.Play
这样的后台播放音乐播放器.是因为您可能无法针对控制台应用程序这样做吗?但是我不明白为什么控制台应用程序无法做到这一点.
I have searched everywhere for this and can't find anything that shows me how to do it, I've only seen instructions for forms applications (When I try to copy what is done in the form app, it doesn't work either). I've tried a couple of "Imports" such as Import System.IO
but they didn't fix the issue. I don't want to open a music player, I want it to be played in the background like My.Computer.Audio.Play
should do. Is it because you can't do it for a console application maybe? However I don't understand why a console apps wouldn't be able to do it.
推荐答案
您确定您的音频文件是.wav吗?来自Microsoft 文档看来您只能播放.wav文件.根据文档,即使在控制台应用程序中也应该可以播放音频文件.
Did you make sure that your audio file is a .wav? From the Microsoft documentation it looks like you can only play .wav files. According to the documentation it should be possible to play audio files even in a console app.
这篇关于尝试在控制台应用程序VB.NET中播放声音的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!