How to add background music?

aite168

Member
Hello!
I want to add background music to my program,and I use "sound("1.wav")" to play the WAV files.But it only plays once. I want it to keep repeat playing until my program end. How can I do?? Have any superiors help me to solve this problem?
I 'm very SORRY about my English!!:sign0013:
 

sitajony

Active Member
Licensed User
Hi, There's PlayLoop function in C#, it's weird that on B4P there's not this features...
I can do this function in few minutes ;)
I'll send you a Library with the source code here...

Français:
Salut, Il y'a une fonction PlayLoop en C#, c'est bizarre que sur B4P il n'ya pas c'ette fonctionnalité...
Je peux le faire en quelques minutes ;)
Je t'enverais une Lib avec le code source ici...
 

sitajony

Active Member
Licensed User
Sorry I can't upload the source code, it return System.Media not found on B4P so the source code may not be merged in the EXE...
This lib have 3 functions:
PlayLoop(File)
PlayOnceTime(File)
Stop
Enjoy and good luck ;)

[PC-PPC-.NET CF 2.0]
 

Attachments

  • PlayWavLoop.zip
    1.6 KB · Views: 389
Last edited:
Hello Sidajony.
Your PlayWavLoop.zip can't be viewed by unlicenced members.:sign0013::sign0013:

I have written a small app with a sound replaying but when the form
is closed the music keeps on playing.
Any idea as to how to stop the sound when the app is stopped?

Sub App_Start
Form1.Show
Timer1.Enabled = True

Sub Timer1_Tick
Timer1.Enabled = False
Sound ("*.wav")
replay
End Sub

Sub replay
Timer1.Interval = 58000 ' the length of the wav file
Timer1.Enabled = True
End Sub
 

sitajony

Active Member
Licensed User
The sound is in the system... The Stop() function will work but it doesn't available on B4P... Maybe if you type this:
Sound("")
I'm not really sure...

Otherwhise:
(For Erel or anybody else)
How know if it's a registred user or not?
 

aite168

Member
Sorry I can't upload the source code, it return System.Media not found on B4P so the source code may not be merged in the EXE...
This lib have 3 functions:
PlayLoop(File)
PlayOnceTime(File)
Stop
Enjoy and good luck ;)

[PC-PPC-.NET CF 2.0]

Hi,sitajony. Thank you for your answer. But when I use your playWavLoop lib,
I still face some problems .

Sound.PlayLoop(AppPath & "\1.wav")

Is this code wrong?? When I run my program,an error occurred,telling me the format of string I inputted is wrong.. Do you know what the problem is .
 

sitajony

Active Member
Licensed User
Hi, Strange... I tested only on my PC and not on my PPC... I test and tell you if it come from my Lib...
 
Hello folks.
Yesturday I said "Your PlayWavLoop.zip can't be viewed by unlicenced members".
I was mistaken as I got cookies turned off in my browser.:sign0148: that is why I couldnt download it.

I want to say that PlayWavLoop won't work with me either.
 
The erro is something like "API supports only playing wave files"
Be sure that i'm using a *.wav file.
I believe your library can only be used in full version of B4p or the latest one as
my device tells me.:cool:
 

sitajony

Active Member
Licensed User
It's telling that you use a wrong file type...
Are you sure that you are playing a WAV file?
It reads only wav files and not MP3, OGG etc...
Normaly it works on any B4P recent version and even if it doesn't registred...
 
Hello Sitajony.
You were right ..... I tested another .wav file and it works well with your library.
The previous one played only with the "sound" keyword and it was about 1 minute long.:(
 

aite168

Member
The erro is something like "API supports only playing wave files"
Be sure that i'm using a *.wav file.
I believe your library can only be used in full version of B4p or the latest one as
my device tells me.:cool:

Your problem is what I want to say.
It is because that your wav file isn't coded by pcm.
It only supports the pcm coded wav file.
You can try to change another wav file.It maybe works.
 

aite168

Member
Now I have another question.

Now I have another question.
How to play another sound file when the backgound sound is playing?
 

sitajony

Active Member
Licensed User
I don't guess that is possible, it use the system sound, when a call tone is played every sounds who are in playing are stoped I think...
Otherwise, there's a library who was available on fmod.org who is "FMODce.dll", it's available on this forum I think, with this lib you can also play MP3, OGG and WAV files with more features...

I hope it will be usefull... Otherwise, try to create 2 objects "PlayWav" but I'm not sure sorry...
 
Top