Wortel Angels Posted August 8, 2012 Author Share Posted August 8, 2012 Thanks Damian666 for the other tutorialI added this tutorial because the most didnt found the things e.c.t.First download: [modDxShow.bas](http://www.file-upload.net/download-6954302/modDxShow.bas.html) and add it to your Project(modDxShow.bas -> client src)(Project -> Add module -> Existing -> Src -> modDxShow.bas)Now go to Project>references and add a ref to active movie control type library.modGeneral search``` ' Cache music liststrLoad = Dir(App.Path & MUSIC_PATH & "*.mid")i = 1Do While strLoad > vbNullStringReDim Preserve musicCache(1 To i) As StringmusicCache(i) = strLoadstrLoad = Diri = i + 1Loop```Add under it``` 'Cache MP3strLoad = Dir(App.Path & MUSIC_PATH & "*.mp3")i = 1Do While strLoad > vbNullStringReDim Preserve musicCache(1 To i) As StringmusicCache(i) = strLoadstrLoad = Diri = i + 1Loop```modGameLogic search``` ' Calculate fpsIf TickFPS < Tick ThenGameFPS = FPSTickFPS = Tick + 1000FPS = 0ElseFPS = FPS + 1End If```add under it``` 'loop mapmusic if needed and its a mp3 fileLoopMp3```modSound search```Public Sub PlayMidi```and replace with```Public Sub PlayMidi(ByVal Filename As String)Dim Splitmusic() As String' If debug mode, handle error then exit outIf Options.Debug = 1 Then On Error GoTo errorhandlerIf Options.Music = 0 Then Exit SubSplitmusic = Split(Filename, ".", , vbTextCompare)If Performance Is Nothing Then Exit SubIf LenB(Trim$(Filename)) < 1 Then Exit SubIf UBound(Splitmusic) <> 1 Then Exit SubIf Not FileExist(App.Path & MUSIC_PATH & Filename, True) Then Exit SubIf Not Music_On Then Exit SubIf Music_Playing = Filename Then Exit SubIf Splitmusic(1) = "mp3" ThenOpenDShowFile (App.Path & MUSIC_PATH & Filename)PlayMp3Exit SubElseIf Splitmusic(1) <> "mid" ThenExit SubEnd IfSet Segment = NothingSet Segment = Loader.LoadSegment(App.Path & MUSIC_PATH & Filename)' repeat midi fileSegment.SetLoopPoints 0, 0Segment.SetRepeats 100Segment.SetStandardMidiFilePerformance.PlaySegment Segment, 0, 0Music_Playing = Filename' Error handlerExit Suberrorhandler:If InGame ThenHandleError "PlayMidi - Ingame = True - Map#= " & Player(MyIndex).Map & " - Filename = " & Filename & " - Filepath Length= " & Len(App.Path & MUSIC_PATH & Filename), "modSound", Err.Number, Err.Description, Err.Source, Err.HelpContextElseHandleError "PlayMidi - Ingame = False - Filename = " & Filename & " - Filepath Length= " & Len(App.Path & MUSIC_PATH & Filename), "modSound", Err.Number, Err.Description, Err.Source, Err.HelpContextEnd IfErr.ClearExit SubEnd Sub```Search```Public Sub StopMidi()```and replace with```Public Sub StopMidi()' If debug mode, handle error then exit outIf Options.Debug = 1 Then On Error GoTo errorhandlerStopMp3If Not (Performance Is Nothing) Then Performance.Stop Segment, Nothing, 0, 0Music_Playing = vbNullString' Error handlerExit Suberrorhandler:HandleError "StopMidi", "modSound", Err.Number, Err.Description, Err.Source, Err.HelpContextErr.ClearExit SubEnd Sub```Credits to Damian666 Link to comment Share on other sites More sharing options...
Lollipopz Posted August 8, 2012 Share Posted August 8, 2012 Thanks a lot.This is great.Though I was lazy so I clicked on the Download EO 2.3 with Mp3 link and pasted all my sprites and tilesets into that. Link to comment Share on other sites More sharing options...
Wortel Angels Posted August 8, 2012 Author Share Posted August 8, 2012 haha No Problem ;-) Im here to help Link to comment Share on other sites More sharing options...
Lollipopz Posted August 8, 2012 Share Posted August 8, 2012 Uhm.. one problem though.I just tried to configure modconstants so it would work with my server but it won't compile,it says:Compile error:Sub or Function not definedonIf Splitmusic(1) = "mp3" Then OpenDShowFile (App.Path & MUSIC_PATH & fileName) PlayMp3 Exit Sub ElseIf Splitmusic(1) <> "mid" Then Exit Sub End IfOpenDShowFile is highlighted. Link to comment Share on other sites More sharing options...
Wortel Angels Posted August 8, 2012 Author Share Posted August 8, 2012 Added reference / moddxshow ???If yes then idk why this appears what did you change Link to comment Share on other sites More sharing options...
Lollipopz Posted August 8, 2012 Share Posted August 8, 2012 I'm using your client, so I think the reference and ModDxShow are already there.Oh and I only changed the max amount maps, items and animations in ModConstants.Nothing but that. Link to comment Share on other sites More sharing options...
Lollipopz Posted August 8, 2012 Share Posted August 8, 2012 Alright, nevermind fixed it.EDIT: Your EO with mp3 support client does not work. The mp3 won't show up in the list.EDIT: Your method works perfectly, decided to add it to my own client and it works fine.Even works in menu. Though you will have to sacrifice your midi files for this. But there's a better collection of mp3's than midi's so it's worth it. Link to comment Share on other sites More sharing options...
Wortel Angels Posted August 9, 2012 Author Share Posted August 9, 2012 thanks for report and bad for double post ;-) Link to comment Share on other sites More sharing options...
Nifflr Posted August 11, 2012 Share Posted August 11, 2012 Thanks, this is a great tutorial. But when I switch maps, even if both maps have the same background music, the song will stop and restart from the beginning again. Is there any way to make it so the song simply continues to play? This is what happened when I used midis, and I very much enjoyed that. If you could offer any assistance, I would really appreciate it. Link to comment Share on other sites More sharing options...
Vus Posted August 11, 2012 Share Posted August 11, 2012 Nice tutorial. This can be useful. Link to comment Share on other sites More sharing options...
erkro1 Posted August 11, 2012 Share Posted August 11, 2012 @Niffler:> Thanks, this is a great tutorial. But when I switch maps, even if both maps have the same background music, the song will stop and restart from the beginning again. Is there any way to make it so the song simply continues to play? This is what happened when I used midis, and I very much enjoyed that. If you could offer any assistance, I would really appreciate it.Client side, in modHandleData, in sub HandleMapDone:```MusicFile = Trim$(Map.Music) If Not MusicFile = "None." Then PlayMidi MusicFile Else StopMidi End If```You should add a check there to check if the current song playing is the map music, and if that is the case dont stop the music. Link to comment Share on other sites More sharing options...
Nifflr Posted August 11, 2012 Share Posted August 11, 2012 That's a good idea, thanks. But unfortunately I'm terrible at coding. What exactly would that check look like?Would it be something sort of like this? I really have no idea. It turns red when I type it in, so I obviously did something wrong.```MusicFile = Trim$(Map.Music)If Not MusicFile = Music_Playing If Not MusicFile = "None." Then PlayMidi MusicFile Else StopMidi End IfEnd If``` Link to comment Share on other sites More sharing options...
erkro1 Posted August 11, 2012 Share Posted August 11, 2012 @Niffler:> That's a good idea, thanks. But unfortunately I'm terrible at coding. What exactly would that check look like?> > Would it be something like this? Or would that just break my game?> ```> MusicFile = Trim$(Map.Music)> If Not MusicFile = Music_Playing> If Not MusicFile = "None." Then> PlayMidi MusicFile> Else> StopMidi> End If> End If> > ```This might work yeah (I've put a missing Then in, I've not testedthe code)```MusicFile = Trim$(Map.Music)If Not MusicFile = Music_Playing Then If Not MusicFile = "None." Then PlayMidi MusicFile Else StopMidi End IfEnd If``` Link to comment Share on other sites More sharing options...
Nifflr Posted August 11, 2012 Share Posted August 11, 2012 Okay, thanks – I just tried putting the Then in. But it doesn't seem to make any difference at all, the song still stops and restarts. Would Music_Playing, even be the right... thing? (do they call that a variable or a string or... I don't even know.) Link to comment Share on other sites More sharing options...
erkro1 Posted August 11, 2012 Share Posted August 11, 2012 @Niffler:> Okay, thanks – I just tried putting the Then in. But it doesn't seem to make any difference at all, the song still stops and restarts. Would Music_Playing, even be the right... thing? (do they call that a variable or a string or... I don't even know.)Put a breakpoint on this line:```If Not MusicFile = Music_Playing Then```Then try doing it, it will stop at that line and the line will turn yellow, when you move your mouse over MusicFile and Music_Playing you will see there comes a tooltip (text in a yellow bar), tell us the text it displays for both MusicFile and Music_Playing. Link to comment Share on other sites More sharing options...
Nifflr Posted August 11, 2012 Share Posted August 11, 2012 @Erwin:> Put a breakpoint on this line:> ```> If Not MusicFile = Music_Playing Then> ```> Then try doing it, it will stop at that line and the line will turn yellow, when you move your mouse over MusicFile and Music_Playing you will see there comes a tooltip (text in a yellow bar), tell us the text it displays for both MusicFile and Music_Playing.Oh, that does seem a problem.MusicFile = "Diagon Alley.mp3"Music_Playing = "" Link to comment Share on other sites More sharing options...
erkro1 Posted August 11, 2012 Share Posted August 11, 2012 Change Music_Playing to CurSong Link to comment Share on other sites More sharing options...
Nifflr Posted August 11, 2012 Share Posted August 11, 2012 CurSong causes Compile Error: Variable not defined. Link to comment Share on other sites More sharing options...
erkro1 Posted August 11, 2012 Share Posted August 11, 2012 @Niffler:> CurSong causes Compile Error: Variable not defined.Ah, keep it Music_Playing and replace PlayMidi with this:```Public Sub PlayMidi(ByVal Filename As String)Dim Splitmusic() As String ' If debug mode, handle error then exit out If Options.Debug = 1 Then On Error GoTo errorhandler If Options.Music = 0 Then Exit Sub Splitmusic = Split(Filename, ".", , vbTextCompare) If Performance Is Nothing Then Exit Sub If LenB(Trim$(Filename)) < 1 Then Exit Sub If UBound(Splitmusic) <> 1 Then Exit Sub If Not FileExist(App.Path & MUSIC_PATH & Filename, True) Then Exit Sub If Not Music_On Then Exit Sub If Music_Playing = Filename Then Exit Sub If Splitmusic(1) = "mp3" Then OpenDShowFile (App.Path & MUSIC_PATH & Filename) PlayMp3 Music_Playing = Filename Exit Sub ElseIf Splitmusic(1) <> "mid" Then Exit Sub End If Set Segment = Nothing Set Segment = Loader.LoadSegment(App.Path & MUSIC_PATH & Filename) ' repeat midi file Segment.SetLoopPoints 0, 0 Segment.SetRepeats 100 Segment.SetStandardMidiFile Performance.PlaySegment Segment, 0, 0 Music_Playing = Filename ' Error handler Exit Suberrorhandler: If InGame Then HandleError "PlayMidi - Ingame = True - Map#= " & Player(MyIndex).Map & " - Filename = " & Filename & " - Filepath Length= " & Len(App.Path & MUSIC_PATH & Filename), "modSound", Err.Number, Err.Description, Err.Source, Err.HelpContext Else HandleError "PlayMidi - Ingame = False - Filename = " & Filename & " - Filepath Length= " & Len(App.Path & MUSIC_PATH & Filename), "modSound", Err.Number, Err.Description, Err.Source, Err.HelpContext End If Err.Clear Exit SubEnd Sub``` Link to comment Share on other sites More sharing options...
Nifflr Posted August 11, 2012 Share Posted August 11, 2012 Oh my goodness! This works! Thank you so much for all your help. You're the best :DWould it be too much to ask you what exactly you did, in hopes that I could learn something? Link to comment Share on other sites More sharing options...
erkro1 Posted August 11, 2012 Share Posted August 11, 2012 @Niffler:> Oh my goodness! This works! Thank you so much for all your help. You're the best :D> Would it be too much to ask you what exactly you did, in hopes that I could learn something?Well, I think you understand the things with the End If case, which checks the map song with the playing song, but I only added Music_Playing = Filename in:```If Splitmusic(1) = "mp3" Then OpenDShowFile (App.Path & MUSIC_PATH & Filename) PlayMp3 Music_Playing = Filename Exit Sub ElseIf Splitmusic(1) <> "mid" Then Exit Sub End If``` Link to comment Share on other sites More sharing options...
Nifflr Posted August 11, 2012 Share Posted August 11, 2012 Ah, okay. I think I understand that. Thanks. You were very helpful. I appreciate it :) Link to comment Share on other sites More sharing options...
Wortel Angels Posted August 11, 2012 Author Share Posted August 11, 2012 I just changed the code which you need to search and the modsound replace ;-) Link to comment Share on other sites More sharing options...
Guest Posted August 20, 2012 Share Posted August 20, 2012 Only trouble is my list only shows .mp3's inthe folder and none of my mids??? Link to comment Share on other sites More sharing options...
Wortel Angels Posted August 22, 2012 Author Share Posted August 22, 2012 read the replyes there you got an "Fix" 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