Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Media Player Sound Replacement
#1
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
Code:
midiloop
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?
Reply
#2
ahh cool, i'll add this thanks robin Big Grin

---------

Just wandering, do you have to replace the whole modSound with wat u have or add that to that code to 1 in it.
Reply
#3
No problem Smile
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?
Reply
#4
i edited my post above, please read Smile
Reply
#5
You don't need to delete anything, but you need to comment out any:

Code:
PlayMidi (w/e)

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?
Reply
#6
What about Sub PlayMidi
Reply
#7
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 Smile
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?
Reply
#8
alright cool. How would this work if u have no play music anywhere inplace of the call playmidi
Reply
#9
Good tutorial Robin Smile 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.
Reply
#10
JokeOfWeek2 Wrote:Good tutorial Robin Smile 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 Smile

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?
Reply
#11
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.
Reply
#12
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 Sad
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?
Reply
#13
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.
Reply
#14
Yay for laziness!

Anyway I could get a playing song to loop?
Reply
#15
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...
Reply
#16
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.
Reply
#17
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?
Reply
#18
I meant that it's being used so *.mp3 and *.wav can be used instead of midi.
Reply
#19
Well, I've been searching, but in vain.

Has anyone else attempted a search?
Reply
#20
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?
Reply
#21
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. -.-
Reply
#22
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?
Reply
#23
Lol, you did what I did.

Cools. n.n
Reply
#24
-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?
Reply
#25
Robin Wrote:-stares at Matts signature-

I did the same for about 2 minutes ;____;
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)