使用.it音乐作为.exe文件中的资源,怎么样? [英] Using .it music as a resource in .exe file, how?

查看:82
本文介绍了使用.it音乐作为.exe文件中的资源,怎么样?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

情况

我一直在处理一个小应用程序,该应用程序读取.nfo文本文件并以自定义形式播放背景音乐。很长一段时间我都让它从系统中读取这些文件,但在这种情况下我必须用我的程序发送文件,然后将它们复制到特定的位置才能工作。

查看我的我完整项目的文章:

作为初学者在C#中创建NFO查看器 [ ^ ]



我想要的申请

在最终版本中,我想在我的应用程序中包含这些文件。

我已经设法将.nfo文本文件添加为资源,所以我没有用我的应用程序发送该文件了。请参阅我如何修复此处 [ ^ ]。

现在我仍然需要弄清楚如何添加和使用.it音乐文件作为资源。我不能把它变成一个文本文件,而我使用的代码总是会向我抛出错误。

我使用以下音乐模拟器来播放这些文件: irrKlang [ ^ ]

再次参考我的文章,了解我必须做什么以及我用什么代码才能使这个工作。

在这些行动之后,它使用以下代码播放来自C:\ Test \的音乐:

Situation:
I''ve been working on a small application that reads a .nfo text file and plays .it music in background in a custom form. For a long time I let it read those files from the system, but in this case I have to sent the files with my program and they have to be copied to a specific location to work.
See my article for my complete project:
Creating a NFO Viewer in C# as a beginner[^]

My desired application:
In the final version I would like to have these files within my application.
I already managed to add the .nfo text file as a resource, so I don''t have to sent that file with my app anymore. See how I fixed that here[^].
Now I still have to figure out how to add and use the .it music file as a resource. I can''t make this a text file and the code I use always throws errors at me.
I use the following music modplayer to play these files: irrKlang[^]
Refer to my Article again to see what I had to do and what code I used to get this working.
After those actions, it plays the music from C:\Test\ with this code:

engine.Play2D("C:\\Test\\Musicfile.it", true);



我想在我的应用程序中播放音乐,因此人们不必将音乐复制/提取到该位置,并且当应用程序运行时音乐会立即运行。

我的最终目标是使用类似


I want the music in my application, so people don''t have to copy/extract the music to that location and that the music runs instantly when my application runs.
My final goal is to use something like

engine.Play2D(Properties.Resources.Musicfile, true)



但我一直收到错误,可能是由于音乐未被识别为音乐造成的,或者方法play2D不喜欢我在第一条评论中使用变量作为''字符串'?



我希望有人可以帮我解决这个问题我的项目的一部分,这是我需要修复以释放我的应用程序的最后步骤之一。

谢谢!


But I keep getting errors, probably caused by the music not being recognised as music, or the method play2D doesn''t like me using a variable as a ''string'' in the first comment?

I hope someone can help me out with this part of my project, it''s one of the last steps I need fixed to release my application.
Thanks!

推荐答案

你可能需要以不同的方式添加音乐文件。



在解决方案资源管理器中右键单击您的项目,单击添加现有项目并添加音乐文件。然后单击音乐文件并单击属性并设置复制到输出目录= true。

之后您可以播放这样的音乐:

You might need to add the music files in a different way.

Right-click your project in the solution explorer, click "Add existing item" and add the music file. Afterwards click on the music file and click on "Properties" and set "Copy to Output Directory" = true.
Afterwards you are able to play your music like this:
engine.Play2D("PathToDirectoryWhereYourExecutableOrDllIsLocated\MusicFile.it", true);


这篇关于使用.it音乐作为.exe文件中的资源,怎么样?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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