Mirage Source
Media Player Sound Replacement - Printable Version

+- Mirage Source (https://mirage-engine.uk/forums)
+-- Forum: Mirage Source (Nostalgia) (https://mirage-engine.uk/forums/forumdisplay.php?fid=61)
+--- Forum: Archive (2006-2011) (https://mirage-engine.uk/forums/forumdisplay.php?fid=18)
+---- Forum: Resources (https://mirage-engine.uk/forums/forumdisplay.php?fid=49)
+---- Thread: Media Player Sound Replacement (/showthread.php?tid=895)

Pages: 1 2


Media Player Sound Replacement - Robin - 22-04-2007

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



- Da Undead - 22-04-2007

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.


- Robin - 22-04-2007

No problem Smile


- Da Undead - 22-04-2007

i edited my post above, please read Smile


- Robin - 22-04-2007

You don't need to delete anything, but you need to comment out any:

Code:
PlayMidi (w/e)

Calls.


- Da Undead - 22-04-2007

What about Sub PlayMidi


- Robin - 22-04-2007

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


- Da Undead - 22-04-2007

alright cool. How would this work if u have no play music anywhere inplace of the call playmidi


- JokeofWeek - 22-04-2007

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.


- Robin - 23-04-2007

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.


- Da Undead - 23-04-2007

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.


- Robin - 23-04-2007

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


- Da Undead - 23-04-2007

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.


- Matt2 - 08-05-2007

Yay for laziness!

Anyway I could get a playing song to loop?


- Boo - 09-05-2007

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...


- Matt - 09-05-2007

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.


- Robin - 09-05-2007

Nope, it's for .mid as well.


- Matt - 09-05-2007

I meant that it's being used so *.mp3 and *.wav can be used instead of midi.


- Matt2 - 10-05-2007

Well, I've been searching, but in vain.

Has anyone else attempted a search?


- Robin - 10-05-2007

For what?


- Matt2 - 10-05-2007

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. -.-


Re: Media Player Sound Replacement - Robin - 10-07-2007

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



Re: Media Player Sound Replacement - Matt2 - 29-07-2007

Lol, you did what I did.

Cools. n.n


Re: Media Player Sound Replacement - Robin - 29-07-2007

-stares at Matts signature-


Re: Media Player Sound Replacement - Tony - 31-07-2007

Robin Wrote:-stares at Matts signature-

I did the same for about 2 minutes ;____;