Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

.NET 

How to Play a Sound in vb.net without having the sound file separately

hey,

i want to play a sound in background without having to provide the path i mean is there any way to like bind the sound with my Project so i can play the sound on any pc without having to provide the sound file separately.


Thanks,
Null
Import it to your resources. You can do this by going to: My project (Double Click) > Resources > Add Resource > File.

Call with: My.Resources.<Identifier>
Either add it to resources or download it from an url.
Code
Dim webclient As New Net.WebClient

Dim sound() As Byte = webclient.DownloadData("http://www.wavsource.com/snds_2014-09-21_2643861498792963/sfx/applause_y.wav")
My.Computer.Audio.Play(sound, AudioPlayMode.Background)
Pretty much like Selcouth just said; Import the soundtrack or mp3 to your resources and then write the code to play it.

http://dbzbt99.weebly.com/how-to-add-bac...basic.html

Hope it helps you!
if i have imported it to the resources and called it, i will have to get the resources folder with my app in order for it to run ?
(Oct 3, 2014 06:56 AM)Vaxorr Wrote:  if i have imported it to the resources and called it, i will have to get the resources folder with my app in order for it to run ?

I recommend streaming the sound from a URL if the client has internet connection.
It will make the download a lot smaller.
(Oct 3, 2014 09:00 AM)PatientZero Wrote:  I recommend streaming the sound from a URL if the client has internet connection.
It will make the download a lot smaller.

Again does not make sense, your speed still depends on server speed / ISP speed, plus the fact it might just happen the server response isn't what you hoped for andthus lagging your entire application since you do not use ASynch stream/download.

Where did you learn to program? sirously..who told you?
My idea is the following.
An if statement to check for internet connection, if yes then download the file and play it if no then copy the sound file provided to a dir like temp, like what odus said. Thoughts ?
(Oct 3, 2014 09:28 AM)TheBarret Wrote:  Again does not make sense, your speed still depends on server speed / ISP speed, plus the fact it might just happen the server response isn't what you hoped for andthus lagging your entire application since you do not use ASynch stream/download.

Where did you learn to program? sirously..who told you?
Maybe then you can host it on your own web-server?
I taught myself and I know how to program thnx.


(Oct 3, 2014 10:42 AM)Vaxorr Wrote:  My idea is the following.
An if statement to check for internet connection, if yes then download the file and play it if no then copy the sound file provided to a dir like temp, like what odus said. Thoughts ?

Sounds good if you can do it 🤝
(Oct 3, 2014 10:42 AM)Vaxorr Wrote:  My idea is the following.
An if statement to check for internet connection, if yes then download the file and play it if no then copy the sound file provided to a dir like temp, like what odus said. Thoughts ?

Reverse you're idea and it would be good.

Check the Temp folders, if the song is not their then download it using webclient and store it in the temp folder. Then play. That way you always download it once.
And use the async method too so your UI doesn't hang.
(Oct 3, 2014 11:09 AM)+Haze Wrote:  Reverse you're idea and it would be good.

Check the Temp folders, if the song is not their then download it using webclient and store it in the temp folder. Then play. That way you always download it once.
And use the async method too so your UI doesn't hang.

"Reverse you're idea and it would be good." - I loled.
(Oct 3, 2014 11:13 AM)Cornflower Blue இڿڰۣ-ڰۣ— Wrote:  "Reverse you're idea and it would be good." - I loled.

😏😏
*your and *there

my bad. Now jog on.
(Oct 3, 2014 11:13 AM)Cornflower Blue இڿڰۣ-ڰۣ— Wrote:  "Reverse you're idea and it would be good." - I loled.

"if the song is not their"

I loled while loling watching loli.
[Image: vjPWhyy.gif]
(Oct 3, 2014 11:16 AM)$lick Wrote:  "if the song is not their"

I loled while loling watching loli.

But it has to be their for it to play. Their going to have to downloaded the song for playing it.


Possibly Related Threads...
Thread / Author Replies Views Last Post
[C#] by LogikJul 10, 2020 03:07 PM 2 152 Jul 10, 2020 03:07 PM
Last Post: Logik
[.NET] by CristianantonuccioJun 24, 2014 10:40 AM 2 132 Jun 24, 2014 10:40 AM
Last Post: nathan72389
[.NET] by Ryan ClearyJun 4, 2014 03:24 AM 12 223 Jun 4, 2014 03:24 AM
Last Post: Dls_