What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Messenger Plus! for Live Messenger » Scripting » Music!Help please!

Music!Help please!
Author: Message:
Light86
Junior Member
**


Posts: 17
Joined: Apr 2007
O.P. Music!Help please!
Hello I know how to make appear a window when contact logs in to msn,sayng "welcome" with an image but I wonder if I could make a short music play when this event occours.
Is this possible?And how?
Thank you!:D
12-23-2007 06:52 PM
Profile E-Mail PM Find Quote Report
Matti
Elite Member
*****

Avatar
Script Developer and Helper

Posts: 1646
Reputation: 39
32 / Male / Flag
Joined: Apr 2004
RE: Music!Help please!
Yes, you can play a sound! :D

The following code is actually written by fatfreechicken, in his awesome Portal credits easter egg of SessionSaver, but it can be used to play almost any music file. All credits for this code go to him! ;)
  1. First, you'll need to get the short path of your music file. This can be done with the following code and should be executed at script start-up or when the window is created. Don't forget to define the sMusicPath variable globally! ;)
    code:
    var sLongPath = MsgPlus.ScriptFilesPath+"\\MerryXmas.mp3"; //The long path to the file. It's recommended that you put the music file in your script directory if you want to distribute your script later on.
    var lpszShortPath = Interop.Allocate((255+1)*2); //A buffer for the short path.
    Interop.Call("kernel32", "GetShortPathNameW", sLongPath, lpszShortPath, 255); //Call the GetShortPathName function to store the short path in our buffer.
    sMusicPath = lpszShortPath.ReadString(0); //Get the contents of the buffer. This is the variable containing the short path which we can use to play the sound.
  2. Next, you need to play the sound. This can be done right after you executed the code above, but you can also do this when the user clicks a button. Anyway, it's up to you to decide where to place the code:
    code:
    Interop.Call("winmm.dll", "mciSendStringW", "play "+sMusicPath, 0, "", 0); //Start playing the sound.
  3. Eventually, you want to stop the sound a bit earlier, or make sure it's stopped when the window is closed. This is done by simply replacing the "play" command with "stop":
    code:
    Interop.Call("winmm.dll", "mciSendStringW", "stop "+sMusicPath, 0, "", 0); //Stop the sound from playing.
And there you have it! ;)
Plus! Script Developer | Plus! Beta Tester | Creator of Countdown Live | Co-developer of Screenshot Sender 5

Found my post useful? Rate me!
12-24-2007 11:13 AM
Profile E-Mail PM Web Find Quote Report
vikke
Senior Member
****

Avatar

Posts: 900
Reputation: 28
31 / Male / Flag
Joined: May 2006
RE: Music!Help please!
Is there a reason not to use MsgPlus.PlaySound()?

You just call it like this:
code:
MsgPlus.PlaySound(PATH);
It supports:
quote:
Microsoft WAV, Sphere Nist (*.wav)
MPEG Audio (*.mp1;*.mp2;*.mp3)
Amiga (*.iff;*.svx)
Apple/SGI (*.aif)
Berkeley/Ircam (*.sf)
Creative Labs (*.voc)
Ensoniq Paris (*.paf)
GNU Octave (*.mat4;*.mat5)
Sound Forge (*.w64)
Sun/Next (*.au;*.snd)
Free Lossless Audio Codec (*.fla;*.flac)
Apple CAF (*.caf)

12-24-2007 11:43 AM
Profile E-Mail PM Find Quote Report
davidpolitis
Full Member
***


Posts: 371
Reputation: 16
Joined: Aug 2006
RE: RE: Music!Help please!
quote:
Originally posted by vikke
Is there a reason not to use MsgPlus.PlaySound()?
MsgPlus.PlaySound() can be really, really laggy when using an actual song for example. Not too sure about fatfreechicken's way. :P
12-24-2007 12:03 PM
Profile PM Find Quote Report
Matti
Elite Member
*****

Avatar
Script Developer and Helper

Posts: 1646
Reputation: 39
32 / Male / Flag
Joined: Apr 2004
RE: Music!Help please!
quote:
Originally posted by vikke
Is there a reason not to use MsgPlus.PlaySound()?
Yes! There's no MsgPlus.StopSound(). :P
Plus! Script Developer | Plus! Beta Tester | Creator of Countdown Live | Co-developer of Screenshot Sender 5

Found my post useful? Rate me!
12-24-2007 12:34 PM
Profile E-Mail PM Web Find Quote Report
davidpolitis
Full Member
***


Posts: 371
Reputation: 16
Joined: Aug 2006
RE: RE: Music!Help please!
quote:
Originally posted by Mattike
There's no MsgPlus.StopSound(). :P
quote:
The MsgPlus::PlaySound function plays a sound asynchronously. It can also be used to stop the current sound from playing.
quote:
If a sound that was started by this function is already playing, it is stopped before the new sound starts playing.
Get it to play a non-existent sound?

This post was edited on 12-24-2007 at 12:45 PM by davidpolitis.
12-24-2007 12:38 PM
Profile PM Find Quote Report
Matti
Elite Member
*****

Avatar
Script Developer and Helper

Posts: 1646
Reputation: 39
32 / Male / Flag
Joined: Apr 2004
RE: Music!Help please!
Okay, I get your point. Choose whichever method you want. :P
Plus! Script Developer | Plus! Beta Tester | Creator of Countdown Live | Co-developer of Screenshot Sender 5

Found my post useful? Rate me!
12-24-2007 03:02 PM
Profile E-Mail PM Web Find Quote Report
pollolibredegrasa
Full Member
***

Avatar
formerly fatfreechicken

Posts: 483
Reputation: 34
35 / Male / Flag
Joined: May 2005
RE: RE: Music!Help please!
quote:
Originally posted by Mattike
Okay, I get your point. Choose whichever method you want. :P
I'll just throw my input in here :P

I'd recommend using MsgPlus.PlaySound() to handle sounds. The only reason I used the code above was because MsgPlus.PlaySound() doesn't support .midi files.

This post was edited on 12-25-2007 at 01:05 AM by pollolibredegrasa.
;p

[Image: chickennana.gif] Vaccy is my thin twin! [Image: chickennana.gif]
12-24-2007 04:57 PM
Profile PM Find Quote Report
« Next Oldest Return to Top Next Newest »


Threaded Mode | Linear Mode
View a Printable Version
Send this Thread to a Friend
Subscribe | Add to Favorites
Rate This Thread:

Forum Jump:

Forum Rules:
You cannot post new threads
You cannot post replies
You cannot post attachments
You can edit your posts
HTML is Off
myCode is On
Smilies are On
[img] Code is On