Carim123 Posted June 16, 2011 Author Share Posted June 16, 2011 Adding a JukeboxFirst off, I am only going to give you the code for the Jukebox. I don't care whether you use another form, embed it into the menu, whatever, that's up to you to decide. If you have trouble with that, don't bug me about it. If you're having trouble with the actual code itself, then bug me.In theory, all this does is echo what it has in Map Properties, while adding a few extra features.First off, if you making a new form, or adding it to frmMain, add this under Option Explicit, in the General Declarations.```Private Declare Function SendMessageByString _ Lib "user32" _ Alias "SendMessageA" _ (ByVal hWnd As Long, _ ByVal wMsg As Long, _ ByVal wParam As Long, _ ByVal lParam As String) _As LongPrivate Const LB_SELECTSTRING = &H18C```This is the basis of our search funtion. Now, where ever you are, add a textbox, a listbox, and three command buttons. You can substitute the command buttons for animated pictures, or images.Name the textbox "txtFind".Name the listbox "lstJuke".Name the three command buttons "cmdPlay", "cmdStop", and "cmdMap". Give them a caption to their function. Name it whatever you like.On your Form_Load (frmMain_Load, in my case.) add…```Dim i As Long, E As String'Start Jukebox If Not hasPopulated Then PopulateLists End If lstJuke.Clear For i = 1 To UBound(musicCache) E = Mid(musicCache(i), 1, (Len(musicCache(i))) - 4) lstJuke.AddItem E Next'End Jukebox```If you'll notice, you'll see that this is more or less the same as the Map Properties music loading. Useful bit of code. :DNow, under txtFind_Change add:``` Dim lngEntryNum As Long Dim strTextToFind As String strTextToFind = txtFind.text lngEntryNum = SendMessageByString(lstJuke.hWnd, _ LB_SELECTSTRING, _ 0, _ strTextToFind)```This is for the search function. That's right, you can search your music as you play!Now, Under cmdPlay…```If Options.Music = 1 Then StopMidi PlayMidi lstJuke.List(lstJuke.ListIndex) & ".mid" Else StopMidi End If```Under cmdStop…```StopMidi```And under cmdMap…```Dim MusicFile As String If Options.Music = 1 Then StopMidi ' start music playing MusicFile = Trim$(Map.Music) If Not MusicFile = "None." Then PlayMidi MusicFile Else StopMidi End If Else Exit Sub End If```And, that should be it. If I've forgotten anything tell me, I don't think I have.You now have a Jukebox!Please, give me credit. Link to comment Share on other sites More sharing options...
Frosty Posted June 16, 2011 Share Posted June 16, 2011 What formats does this play? Link to comment Share on other sites More sharing options...
Carim123 Posted June 16, 2011 Author Share Posted June 16, 2011 @Frosty:> What formats does this play?It's still Midi. Link to comment Share on other sites More sharing options...
kibbelz Posted June 16, 2011 Share Posted June 16, 2011 Hmm, it looks nice. Good job. Link to comment Share on other sites More sharing options...
MrKris Posted June 17, 2011 Share Posted June 17, 2011 Nice feature to have in a game, I like it a lot. Great work. Link to comment Share on other sites More sharing options...
Darth Tyllo Posted June 19, 2011 Share Posted June 19, 2011 It says lstJuke is undefined, now, I know I'm not the best with vb6, but i do believe I followed this correctly, do you have any idea where I may have slipped up? Link to comment Share on other sites More sharing options...
Ruins of Hell Posted June 19, 2011 Share Posted June 19, 2011 @Darth:> It says lstJuke is undefined, now, I know I'm not the best with vb6, but i do believe I followed this correctly, do you have any idea where I may have slipped up?> This is the basis of our search funtion. Now, where ever you are, add a textbox, a listbox, and three command buttons. You can substitute the command buttons for animated pictures, or images.> > Name the textbox "txtFind".> Name the listbox "lstJuke".> Name the three command buttons "cmdPlay", "cmdStop", and "cmdMap". Give them a caption to their function. Name it whatever you like. Link to comment Share on other sites More sharing options...
Conra Posted June 19, 2011 Share Posted June 19, 2011 @Darth:> It says lstJuke is undefined, now, I know I'm not the best with vb6, but i do believe I followed this correctly, do you have any idea where I may have slipped up?That would have never happened if you used the great Automagic system made by our very own mod, Soul. Do you think you could make an Automagic installer Hamster Boy??? Anyway, nice tut. Link to comment Share on other sites More sharing options...
Carim123 Posted June 21, 2011 Author Share Posted June 21, 2011 @D.J.:> That would have never happened if you used the great Automagic system made by our very own mod, Soul. Do you think you could make an Automagic installer Hamster Boy??? Anyway, nice tut.No thanks, this is too simple to make the hassle. Link to comment Share on other sites More sharing options...
SpiceyWolf Posted July 17, 2011 Share Posted July 17, 2011 I keep getting an error on the lstjuke.clear code…(the one on load_form)where it sais "for i = bla... it highlights I and sais type not defined...how do i fix this? Link to comment Share on other sites More sharing options...
Carim123 Posted July 17, 2011 Author Share Posted July 17, 2011 Sorry, forgot a vital part.Add``` Dim i As Long```Under the start of the Form_Load. Link to comment Share on other sites More sharing options...
SpiceyWolf Posted July 17, 2011 Share Posted July 17, 2011 TY TY TY SO MUCH! I LOVE IT!!! Link to comment Share on other sites More sharing options...
Darth Tyllo Posted August 8, 2011 Share Posted August 8, 2011 Ah, thanks, I tried this again after a while, and whatever I messed up with last time, I got it right this time, and it works perfectly! Plus, it's extra incentive for me to start messing with the gui, so I can replace the ugly "Open" Command Button I made to test it! Thanks for the cool feature, I really like that you can search for the track you want to hear! Oh, one more thing. Is there a way to hide the ".mid" part on the list? It's not extremely important, as of right now, but it would just look a bit better, at least to me. Link to comment Share on other sites More sharing options...
Carim123 Posted August 8, 2011 Author Share Posted August 8, 2011 @Darth:> Ah, thanks, I tried this again after a while, and whatever I messed up with last time, I got it right this time, and it works perfectly! Plus, it's extra incentive for me to start messing with the gui, so I can replace the ugly "Open" Command Button I made to test it! Thanks for the cool feature, I really like that you can search for the track you want to hear! Oh, one more thing. Is there a way to hide the ".mid" part on the list? It's not extremely important, as of right now, but it would just look a bit better, at least to me.To hide the .mid, change the Dim i As Long to;``` Dim i As Long, E As String```Then under For i = 1 To UBound(musicCache), to the Next, remove the middle, and change it to;``` E = Mid(musicCache(i), 1, (Len(musicCache(i))) - 4) lstJuke.AddItem E``` Link to comment Share on other sites More sharing options...
Darth Tyllo Posted August 8, 2011 Share Posted August 8, 2011 There's now a problem with the code; it doesn't play the midi when you hit Play. I've been trying to find the solution, but to no avail, I can't find a way too fix it. I'll keep trying, as I'm sure it's right under my nose. I'll post it if I can find the answer! Link to comment Share on other sites More sharing options...
Carim123 Posted August 8, 2011 Author Share Posted August 8, 2011 @Darth:> There's now a problem with the code; it doesn't play the midi when you hit Play. I've been trying to find the solution, but to no avail, I can't find a way too fix it. I'll keep trying, as I'm sure it's right under my nose. I'll post it if I can find the answer!Ah, sorry, another thing I forgot to give you…Change``` PlayMidi lstJuke.List(lstJuke.ListIndex)```to…``` PlayMidi lstJuke.List(lstJuke.ListIndex) & ".mid"``` Link to comment Share on other sites More sharing options...
Darth Tyllo Posted August 8, 2011 Share Posted August 8, 2011 Thanks, this is great! Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now