在控制台应用程序中添加声音文件 [英] Adding sound files in console applications

查看:75
本文介绍了在控制台应用程序中添加声音文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的教授要求我将声音文件添加到我已经创建的任何程序中.他说这很容易做到,但是我进行了搜索,但似乎没有找到任何可以帮助我开始这一过程的东西.我敢肯定,你们中的一个知道这一点,我只需要一些指导或其他内容.我正在尝试在课堂上学习这些东西.我正在寻找实现此目的的任何简单方法以及控制音量的方法.如果有人可以提供指向我可以找到该信息的地方的链接,那将有所帮助.可能的代码片段或任何有助于我完成此工作的内容.

我找到了这个,但不确定是否这是我需要开始的地方.

System.Diagnostics.Process.Start("[Path] .mp3");它打开在本地计算机上确定的适当的播放器(通常是Media Player)并播放音乐.

那对我来说是一个开始吗?记住我说过这是一个控制台应用程序,而不是Windows应用程序.

I was asked by my professor to add a sound file to any program I have created already. He said its fairly easy to do, but I have searched and search, but not seem to find anything that would help me start this process. I am sure one of you knows this, I just need some guidance or something. I am trying to learn this stuff for class. I am looking for the any simple ways to do this and ways to control volumes as well. If someone could provide links to places where I could find the information would help. Possible code snippits or anything to assist me in this.

i found this, but not sure if this is where i need to start.

System.Diagnostics.Process.Start("[Path].mp3");it opens the appropriate player which is determined on the local machine(ususally Media Player) and play the music.

would that be a start for me? Remember I said this is a console application not a windows application.

推荐答案

看看 Windows Media Player [ ^ ]组件,它播放几种文件类型,并具有控制音量的属性.但是,它要求在计算机上安装WMP,而且我不确定它是否可以与GUI应用程序一起使用.

我只是放在一起一个小的控制台应用程序,以查看WMP组件是否可以与控制台应用程序一起使用,并且可以正常工作.但是,我不确定这是否是最好的方法,但它是否满足您的要求.

阅读 [
Have a look at the SoundPlayer[^] class.

It only plays WAV files and doesn''t have any methods/properties to control the volume (as far as I know), but I''d say it''s a start for you.

Otherwise there''s the Windows Media Player[^] component, which plays several file types, and has a property to control the volume. However, it requires WMP to be installed on the computer, and I''m not really sure if it works with anything else than GUI applications.

I just put together a small console app to see if the WMP component works with console applications, and it''s working alright. However, I''m not sure if it''s the best approach, but it meets your requirements.

Read this[^] for information on how to add it to your project.


这篇关于在控制台应用程序中添加声音文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆