Windows Develop Bookmark and Share   
 index > Windows Forms General > Problem with the SoundPlayer control
 

Problem with the SoundPlayer control

i've created a c# windows appicationusing visual studio.net 2005,

its a memory game with sound and everthing,

everything is working fine, i published it and i want to start distributing it but here lies the problem.

in my code, the SoundPlayer Locations are all paths onmy PC, and now if i try to run it anywhere else (different locations on myPC or on different PCs) the sound doesn't work (naturally since the paths in the code are the same!) plus i dont want to use a web URL...

now my question is how do i fix this, how do i provide locations for the SoundPlayer control so that it works on any computer anywhere, regardless of the location of the sound files and without using a URL??

please help ASAP..

mOohA_  Wednesday, April 25, 2007 3:43 PM
mOohA! wrote:

i've created a c# windows appicationusing visual studio.net 2005,

its a memory game with sound and everthing,

everything is working fine, i published it and i want to start distributing it but here lies the problem.

in my code, the SoundPlayer Locations are all paths onmy PC, and now if i try to run it anywhere else (different locations on myPC or on different PCs) the sound doesn't work (naturally since the paths in the code are the same!) plus i dont want to use a web URL...

now my question is how do i fix this, how do i provide locations for the SoundPlayer control so that it works on any computer anywhere, regardless of the location of the sound files and without using a URL??

please help ASAP..

Simply put the sound files in a folder named Sounds in the same directory as of exe file and then use the relative path like this:

\\..\\Sounds\\Sound1.wav

or

@\..\Sounds\Sound1.wav

I hope this will help.

Best Regards,

Rizwan aka RizwanSharp

RizwanSharp  Wednesday, April 25, 2007 7:17 PM
In the install program, create a Custom Action, to divine where the sound player is located and write that info to the registry. When your app starts look for that registry item and use its path.
OmegaMan  Wednesday, April 25, 2007 4:19 PM

that's great, but the problem with the installer is that it's built into the visual studio.net and doesn't provide any customization..

a friend recommended i use the Nullsoft Install System but i have 0 knowledge when it comes to installers,

plus i'm kinda new to programming which adds up to the dilemma..

what should i do??

mOohA_  Wednesday, April 25, 2007 4:36 PM
mOohA! wrote:

that's great, but the problem with the installer is that it's built into the visual studio.net and doesn't provide any customization..

a friend recommended i use the Nullsoft Install System but i have 0 knowledge when it comes to installers,

plus i'm kinda new to programming which adds up to the dilemma..

what should i do??



You will have to be more specific on customization. It does provide a basic framework to install and the concept I mentioned can be done within its system.

Here is a link to a Walktrhrough: Creating a custom install action , it mentions VB project, but one can do a C# project as a stand alone assembly that is included with the install. Basically anything that can be done in C# can be done in the install, hence a perfect place to query the system for the information and store it in the registry.
OmegaMan  Wednesday, April 25, 2007 5:56 PM
mOohA! wrote:

i've created a c# windows appicationusing visual studio.net 2005,

its a memory game with sound and everthing,

everything is working fine, i published it and i want to start distributing it but here lies the problem.

in my code, the SoundPlayer Locations are all paths onmy PC, and now if i try to run it anywhere else (different locations on myPC or on different PCs) the sound doesn't work (naturally since the paths in the code are the same!) plus i dont want to use a web URL...

now my question is how do i fix this, how do i provide locations for the SoundPlayer control so that it works on any computer anywhere, regardless of the location of the sound files and without using a URL??

please help ASAP..

Simply put the sound files in a folder named Sounds in the same directory as of exe file and then use the relative path like this:

\\..\\Sounds\\Sound1.wav

or

@\..\Sounds\Sound1.wav

I hope this will help.

Best Regards,

Rizwan aka RizwanSharp

RizwanSharp  Wednesday, April 25, 2007 7:17 PM

FINALLY!!!! thanxrizwan ur da best!Wink

hehe i guess ur native language IS c# lolStick out tongue

thnx again man c",)
mOohA_  Wednesday, April 25, 2007 8:35 PM
mOohA! wrote:

FINALLY!!!! thanx rizwan ur da best!

hehe i guess ur native language IS c# lol

thnx again man c",)


When I read your initial post, it sounded, the path was not to data files, but an actual sound player location that was outside your created application...
OmegaMan  Wednesday, April 25, 2007 9:13 PM

You can use google to search for other answers

Custom Search

More Threads

• ComboBox Raise ShowItemsList Event
• Complex dividing interface
• Animated gif panel
• Resizing and Repositioning Control on a Windows Form at runtime(.Net)
• Optimal painting using double buffering
• I feel dumb, but...
• How to display Access Key without press Alt key?
• application design opinion
• Setting a Control to use many usercontrols
• Scaling Windows Forms