What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Messenger Plus! for Live Messenger » Scripting » Q about PlaySound()

Q about PlaySound()
Author: Message:
Matti
Elite Member
*****

Avatar
Script Developer and Helper

Posts: 1646
Reputation: 39
32 / Male / Flag
Joined: Apr 2004
RE: Q about PlaySound()
That'll probably work (look okay, haven't tested though). However, there are some things you should consider:
  • With that code, you're going to download the .mp3 file every time you click the menu item. I don't know what the purpose of your script is, but wouldn't it be better to download it only the first time to a known location and just play the local file every time it's called afterwards?
  • More importantly: your script is responsible for the clean-up of the downloaded files. That means, if you download a file to a temporary location, Plus! won't delete it when the script terminates. When you don't clean up your temporary files, you'll end up with a big mess of files in your Temp directory.
    Therefore, it would be better if you keep track of all downloaded files and schedule them for deletion on script termination:
    Javascript code:
    // Global array to store downloaded files in
    var arrDownloaded = [];
     
    // On exit, loop through the array and remove all downloaded files
    function OnEvent_Uninitialize() {
        var FSO = new ActiveXObject("Scripting.FileSystemObject");
        var i = arrDownloaded.length;
        while(i--) {
            try { FSO.GetFile(arrDownloaded[i]).Delete(); } catch(e) { }
        }
        arrDownloaded = [];
    }
     
    // On download complete, add the file to the downloaded files array
    function OnEvent_DownloadFileComplete(Url, OutFile, Success) {
        Debug.Trace("DownloadFileComplete event received for " + Url);
        Debug.Trace("   Success: " + Success);
        if(Success) {
            arrDownloaded.push(OutFile);        MsgPlus.PlaySound(OutFile);
        }
    }

Plus! Script Developer | Plus! Beta Tester | Creator of Countdown Live | Co-developer of Screenshot Sender 5

Found my post useful? Rate me!
05-12-2010 11:29 AM
Profile E-Mail PM Web Find Quote Report
« Next Oldest Return to Top Next Newest »

Messages In This Thread
Q about PlaySound() - by hakxx on 05-11-2010 at 02:52 PM
RE: Q about PlaySound() - by matty on 05-11-2010 at 02:57 PM
RE: Q about PlaySound() - by hakxx on 05-11-2010 at 03:51 PM
RE: Q about PlaySound() - by matty on 05-11-2010 at 04:40 PM
RE: Q about PlaySound() - by hakxx on 05-11-2010 at 04:45 PM
RE: Q about PlaySound() - by matty on 05-11-2010 at 05:27 PM
RE: Q about PlaySound() - by hakxx on 05-11-2010 at 11:58 PM
RE: Q about PlaySound() - by Matti on 05-12-2010 at 11:29 AM
RE: Q about PlaySound() - by matty on 05-12-2010 at 01:44 PM
RE: Q about PlaySound() - by hakxx on 05-13-2010 at 06:07 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