Posts: 2,742
Threads: 115
Joined: Jun 2006
Reputation:
0
MediaPlayer Supported Sound
Much shorter than FMod.
Refrences
Code: Windows Media Player
Location: C:\WINDOWS\system32\msdxm.ocx
modSound
Code: Public MusicPlayer As New MediaPlayer.MediaPlayer
Public CurrentSong As String
Public Sub PlayMusic(ByVal Song As String)
If Song CurrentSong Then
MusicPlayer.Open App.Path & "\data\music\" & Song
CurrentSong = Song
End If
End Sub
Syntax
Code: PlayMusic "Ripple.mp3"
sub GameDestroy
Code: MusicPlayer.Stop
Set MusicPlayer = Nothing
Sub HandleData (just after "Unload frmMapProperties")
Code: PlayMusic SaveMap.Music & ".mid"
OPTIONAL EXTRA: PREVIEW MAP MUSIC IN EDITOR
frmMapProperties
Code: Private Sub Command1_Click()
PlayMusic scrlMusic.Value & ".mid"
End Sub
OPTIONAL EXTRA: LOOPING SONGS
frmSound
Code: Public Sub MidiLoop()
If MusicPlayer.PlayState = mpStopped Then
MusicPlayer.Play
End If
End Sub
Sub GameLoop
Quote:Robin:
Why aren't maps and shit loaded up in a dynamic array?
Jacob:
the 4 people that know how are lazy
Robin:
Who are those 4 people?
Jacob:
um
you, me, and 2 others?
ahh cool, i'll add this thanks robin
---------
Just wandering, do you have to replace the whole modSound with wat u have or add that to that code to 1 in it.
Posts: 2,742
Threads: 115
Joined: Jun 2006
Reputation:
0
No problem
Quote:Robin:
Why aren't maps and shit loaded up in a dynamic array?
Jacob:
the 4 people that know how are lazy
Robin:
Who are those 4 people?
Jacob:
um
you, me, and 2 others?
i edited my post above, please read
Posts: 2,742
Threads: 115
Joined: Jun 2006
Reputation:
0
You don't need to delete anything, but you need to comment out any:
Calls.
Quote:Robin:
Why aren't maps and shit loaded up in a dynamic array?
Jacob:
the 4 people that know how are lazy
Robin:
Who are those 4 people?
Jacob:
um
you, me, and 2 others?
Posts: 2,742
Threads: 115
Joined: Jun 2006
Reputation:
0
Da Undead Wrote:What about Sub PlayMidi
Well, if it's never been called it's not doing any harm. Might as well keep it there
Quote:Robin:
Why aren't maps and shit loaded up in a dynamic array?
Jacob:
the 4 people that know how are lazy
Robin:
Who are those 4 people?
Jacob:
um
you, me, and 2 others?
alright cool. How would this work if u have no play music anywhere inplace of the call playmidi
Good tutorial Robin  Only thing is, not everyone is up to date with the Windows Media Player control. If I remember right (I had implemented this once), there are two different versions of the control with the same name, but the syntax for using them was different. Sorry if I'm wrong, just thought you should know.
Posts: 2,742
Threads: 115
Joined: Jun 2006
Reputation:
0
JokeOfWeek2 Wrote:Good tutorial Robin Only thing is, not everyone is up to date with the Windows Media Player control. If I remember right (I had implemented this once), there are two different versions of the control with the same name, but the syntax for using them was different. Sorry if I'm wrong, just thought you should know.
I'm pretty sure it will work no matter how old windows media player is, because all we are doing is using the very, very basic funtions (play mp3, mid, wav etc.) and stop them.
I'm also pretty sure I used the correct version. I looked around and that was the reference people used when working with it.
Please correct me if I'm wrong.
Dave Wrote:Cool. Does it work with old WMP versions, also does WMP (and other programs that use this control) still work while the music in the game is playing?
It does for me. You can have sound coming out of both the game and Windows Media Player at the same time, but make sure you give people to option to turn off sound
As for older WMP versions, I'm 99% sure it does.
Quote:Robin:
Why aren't maps and shit loaded up in a dynamic array?
Jacob:
the 4 people that know how are lazy
Robin:
Who are those 4 people?
Jacob:
um
you, me, and 2 others?
I been wandering about a like built-in music player where plays music based off 'watever folder name' and can be anything xD. Like having ur own playlist :p. So u don't have to have like Musicmatch/Windows Media/Jukebox, etc... open xD.
Posts: 2,742
Threads: 115
Joined: Jun 2006
Reputation:
0
I had that for one of the Nr versions.
I stole a code which searched through the PC for music files, and then allowed users to add these into playlists (or load existing WMP playlists) and play them accordingly.
Don't have the source anymore though
Quote:Robin:
Why aren't maps and shit loaded up in a dynamic array?
Jacob:
the 4 people that know how are lazy
Robin:
Who are those 4 people?
Jacob:
um
you, me, and 2 others?
make another xD. How about make it check any type of .mp3 or .wav file in like 'music' folder. And then just add little pic box with stuff :p.
Yay for laziness!
Anyway I could get a playing song to loop?
Hmm, I know ShockWave has an .Loop command, but idk if you can use that for Sound :\
But I would thing it should loop on its own unless you got an stop midi or w-e...
This is for *.mp3 and *.wav files. Not midi.
Windows media player has a loop (repeat) function. There has to be a way to call this using this method. I'm sure.
Posts: 2,742
Threads: 115
Joined: Jun 2006
Reputation:
0
Nope, it's for .mid as well.
Quote:Robin:
Why aren't maps and shit loaded up in a dynamic array?
Jacob:
the 4 people that know how are lazy
Robin:
Who are those 4 people?
Jacob:
um
you, me, and 2 others?
I meant that it's being used so *.mp3 and *.wav can be used instead of midi.
Well, I've been searching, but in vain.
Has anyone else attempted a search?
Posts: 2,742
Threads: 115
Joined: Jun 2006
Reputation:
0
For what?
Quote:Robin:
Why aren't maps and shit loaded up in a dynamic array?
Jacob:
the 4 people that know how are lazy
Robin:
Who are those 4 people?
Jacob:
um
you, me, and 2 others?
Advocate Wrote:This is for *.mp3 and *.wav files. Not midi.
Windows media player has a loop (repeat) function. There has to be a way to call this using this method. I'm sure.
^This^
[edit] Lol, no one has either attempted, or found anything, have we?
Well, I'm trying out all sorts of things. When I get it working, Robin, you can add it to your tut. -.-
Posts: 2,742
Threads: 115
Joined: Jun 2006
Reputation:
0
For anyone who hasn't found it out yet and wants to know, here's how to make the song loop.
add this sub to modSound and call it during gameloop.
Code: Public Sub MidiLoop()
If MusicPlayer.PlayState = mpStopped Then
MusicPlayer.Play
End If
End Sub
Quote:Robin:
Why aren't maps and shit loaded up in a dynamic array?
Jacob:
the 4 people that know how are lazy
Robin:
Who are those 4 people?
Jacob:
um
you, me, and 2 others?
Lol, you did what I did.
Cools. n.n
Posts: 2,742
Threads: 115
Joined: Jun 2006
Reputation:
0
-stares at Matts signature-
Quote:Robin:
Why aren't maps and shit loaded up in a dynamic array?
Jacob:
the 4 people that know how are lazy
Robin:
Who are those 4 people?
Jacob:
um
you, me, and 2 others?
Robin Wrote:-stares at Matts signature-
I did the same for about 2 minutes ;____;
|