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:
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
« Next Oldest Return to Top Next Newest »

Messages In This Thread
Music!Help please! - by Light86 on 12-23-2007 at 06:52 PM
RE: Music!Help please! - by Matti on 12-24-2007 at 11:13 AM
RE: Music!Help please! - by vikke on 12-24-2007 at 11:43 AM
RE: RE: Music!Help please! - by davidpolitis on 12-24-2007 at 12:03 PM
RE: Music!Help please! - by Matti on 12-24-2007 at 12:34 PM
RE: RE: Music!Help please! - by davidpolitis on 12-24-2007 at 12:38 PM
RE: Music!Help please! - by Matti on 12-24-2007 at 03:02 PM
RE: RE: Music!Help please! - by pollolibredegrasa on 12-24-2007 at 04:57 PM


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