Click here to Skip to main content
15,886,199 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
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:
C#
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
C#
engine.Play2D(Properties.Resources.Musicfile, true)

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!
Posted
Comments
DarkTyranno 10-Jan-13 9:38am    
No one interested in helping me out with this? :(

1 solution

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:
C#
engine.Play2D("PathToDirectoryWhereYourExecutableOrDllIsLocated\MusicFile.it", true);
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900