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

.NET 

[TUT] How to make your project play Music! [EXTREMELY NOOB FRIENDLY!]

Requirements;
Visual Basic 2008
A song (If you don't have a song, there's a song coming with Windows, the location is: C:\WINDOWS\Media and it's called 'Onestop'


1. So first what we have to do, is create a new project, name it whatever you want;
[img]http://i1091.photobucket.com/albums/i384/Bossmous/1.jpg[/img]
2. Now you should get a window like this, if you don't, repeat step 1;
[IMG]http://i1091.photobucket.com/albums/i384/Bossmous/2.jpg[/IMG]
3. Now doubleclick anywhere, I decided to doubleclick in the red square area. (The red square was added by me in paint, it's not supposed to be there in your project)
[IMG]http://i1091.photobucket.com/albums/i384/Bossmous/3.jpg[/IMG]
4. You should now see the source code, now add this code. To make it work, it MUST be a valid location and the file should also be located there! Make sure the format of the file is right aswell.

Quote: AxWindowsMediaPlayer1.URL = ("C:\Project1\1.mp3")

Code explanation;
Spoiler (Click to View)
[IMG]http://i1091.photobucket.com/albums/i384/Bossmous/5.jpg[/IMG]

5. You should now get an error, that AxWindowsMediaPlayer1 is not declared, to do that, click on the 'Design' at the top, and then rightclick in the toolbox and click 'Choose items'
[IMG]http://i1091.photobucket.com/albums/i384/Bossmous/6.jpg[/IMG]
6. Select the COM tab, and scroll ALL the way to the bottom, and select 'Windows Media Player' and press Ok.
[IMG]http://i1091.photobucket.com/albums/i384/Bossmous/7.jpg[/IMG]
7. You should now see a Windows Media Player item in the toolbox, doubleclick it and it should appear in your project/form.
[IMG]http://i1091.photobucket.com/albums/i384/Bossmous/8.jpg[/IMG]
8. Now you can do alittle what you want, but I chose to do so it will play automatically and also hide the media player, so the form will be empty but still play music. You can do this by making your code look like this;
[IMG]http://i1091.photobucket.com/albums/i384/Bossmous/9.jpg[/IMG]
9. You can also make the music play if the user would press a button or something like that, in that case, you must add a button to the form and the code should look like this;
[IMG]http://i1091.photobucket.com/albums/i384/Bossmous/10.jpg[/IMG]

Now we are done! Here is the result for me; (Feel free to post yours!)



(The volume is kind of low, the song is called 'The Somatic Defilement' by 'Whitechapel'.

Extra notes;
Change the code for the location for the audio file to "AxWindowsMediaPlayer1.URL = (Application.StartupPath & "\1.mp3")" if you're going to have the audio file and the .exe file in the same folder! :)

Thanks!
Credits; 100% to Bossmous for the pictures, the text and the video.

Downloads;
Source code & done project here;
Mediafire
Uppit (Mirror)
Thanks for the tutorial, will come in handy.
Quality TUT, like delluzion said it will come in extra handy.
Nice tut, not to destroy anything, but i even made a video for this 2 years ago.

Depends if you're up to videos or to textbased tuts :)

Keep it up! 👍

Spoiler (Click to View)

Yup, mute works!
If you give someone that project, there will be no music on his side ;)
[Image: ok2LiGx.jpg]
(Jun 26, 2011 05:10 AM)Uncol Dolan Wrote:  If you give someone that project, there will be no music on his side ;)

You're right, and at the same time wrong :)

I changed it so it looks like this; "AxWindowsMediaPlayer1.URL = (Application.StartupPath & "\1.mp3")"
and included the audio file with the download :)
I got a problem.
I did this but when I launch my application on an other folder, it says: Error, stopped working.
It only works in the "Debug" folder.
Good tut. Lol i might use this. Thanks for the share.
(Jun 26, 2011 09:44 AM)MoonWoLF Wrote:  I got a problem.
I did this but when I launch my application on an other folder, it says: Error, stopped working.
It only works in the "Debug" folder.

Can you C&P your whole code in here or send me a PM please? I'll try to fix it for ya!
(Jun 26, 2011 09:56 AM)Bossmous Wrote:  Can you C&P your whole code in here or send me a PM please? I'll try to fix it for ya!

Same as yours :)
I can only run the app on my Debugfolder, if I place my app on the desktop, it won't work.
(Jun 26, 2011 10:00 AM)w0lv3s Wrote:  Same as yours :)
I can only run the app on my Debugfolder, if I place my app on the desktop, it won't work.

Make sure you include the .dll files and the audio file, it works for me :S
(Jun 26, 2011 10:00 AM)w0lv3s Wrote:  Same as yours :)
I can only run the app on my Debugfolder, if I place my app on the desktop, it won't work.

Try to publish the app instead of debugging it and then picking the .exe from the publish folder. There might be some resources that are screwed :P

Might work! 👍
Same problem, there aren't any hidden files, I copy all the files and paste them in another folder and it gives me the rror: stopped working ..
(Jun 26, 2011 10:20 AM)w0lv3s Wrote:  Same problem, there aren't any hidden files, I copy all the files and paste them in another folder and it gives me the rror: stopped working ..

Can you post the code of yours in a spoiler in this thread? It would help me solve the problem.
Same as moonwolf, and the same code of OP.


Possibly Related Threads...
Thread / Author Replies Views Last Post
[Python] by SIM-2362662Jan 12, 2020 05:30 PM 5 212 Jan 12, 2020 05:30 PM
Last Post: Riԁdle
[.NET] by _UnderDogDec 1, 2016 12:22 AM 2 308 Dec 1, 2016 12:22 AM
Last Post: _UnderDog
[Python] by ScrewbaccaNov 7, 2016 09:28 AM 28 3,646 Nov 7, 2016 09:28 AM
Last Post: gamerstech