What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Messenger Plus! for Live Messenger » Scripting » how to filter the music?

how to filter the music?
Author: Message:
roflmao456
Skinning Contest Winner
****

Avatar

Posts: 955
Reputation: 24
30 / Male / Flag
Joined: Nov 2006
Status: Away
O.P. Huh?  how to filter the music?
how do i filter the Messenger.MyCurrentMedia thing? i need help :(

it always ends up like {0}\Music or something like that >_>..
[quote]
Ultimatess6
: What a noob mod
11-21-2006 03:13 AM
Profile PM Web Find Quote Report
Matti
Elite Member
*****

Avatar
Script Developer and Helper

Posts: 1646
Reputation: 39
32 / Male / Flag
Joined: Apr 2004
RE: how to filter the music?
You should use a regular expression for that.

Here's a small function which will return an array containing the information out of a media string.
code:
function parseMedia(Media) {
   var mediaExp = /^\\0([a-z]+)\\0([0-1])\\0(.*)\\0(.*)\\0(.*)\\0(.*)\\0(.*)\\0$/i;
   if(typeof(Media) == "string" && mediaExp.test(Media)) {
      var arr = new Array();
      arr['type'] = RegExp.$1;
      arr['enabled'] = RegExp.$2;
      arr['format'] = RegExp.$3;
      arr['title'] = RegExp.$4;
      arr['artist'] = RegExp.$5;
      arr['album'] = RegExp.$6;
      arr['contentId'] = RegExp.$7;
      return arr;
   } else {
      return false;
   }
}
An example to use this:
code:
var arrMedia = parseMedia(Messenger.MyCurrentMedia);
if(!arrMedia) {
   //Here you can work with the arrMedia array
   Debug.Trace("Now Playing: " + arrMedia['artist'] + " - " + arrMedia['title'];
} else {
   //The media string was invalid
}
;)
Plus! Script Developer | Plus! Beta Tester | Creator of Countdown Live | Co-developer of Screenshot Sender 5

Found my post useful? Rate me!
11-21-2006 05:27 PM
Profile E-Mail PM Web Find Quote Report
roflmao456
Skinning Contest Winner
****

Avatar

Posts: 955
Reputation: 24
30 / Male / Flag
Joined: Nov 2006
Status: Away
O.P. RE: RE: how to filter the music?
quote:
Originally posted by Mattike
You should use a regular expression for that.

Here's a small function which will return an array containing the information out of a media string.
code:
function parseMedia(Media) {
   var mediaExp = /^\\0([a-z]+)\\0([0-1])\\0(.*)\\0(.*)\\0(.*)\\0(.*)\\0(.*)\\0$/i;
   if(typeof(Media) == "string" && mediaExp.test(Media)) {
      var arr = new Array();
      arr['type'] = RegExp.$1;
      arr['enabled'] = RegExp.$2;
      arr['format'] = RegExp.$3;
      arr['title'] = RegExp.$4;
      arr['artist'] = RegExp.$5;
      arr['album'] = RegExp.$6;
      arr['contentId'] = RegExp.$7;
      return arr;
   } else {
      return false;
   }
}
An example to use this:
code:
var arrMedia = parseMedia(Messenger.MyCurrentMedia);
if(!arrMedia) {
   //Here you can work with the arrMedia array
   Debug.Trace("Now Playing: " + arrMedia['artist'] + " - " + arrMedia['title'];
} else {
   //The media string was invalid
}
;)


when i use it in the OnEvent_MyMediaChange function it ends up as undefined... i just copied and pasted the code
[quote]
Ultimatess6
: What a noob mod
11-21-2006 09:15 PM
Profile PM Web Find Quote Report
Spunky
Former Super Mod
*****

Avatar

Posts: 3658
Reputation: 61
36 / Male / Flag
Joined: Aug 2006
RE: how to filter the music?
It is an error on your part as the function works fine...

code:
var MediaInfo = new Array();

function OnEvent_MyMediaChange(NewMedia){
      MediaInfo = parseMedia(NewMedia);
      for(i in MediaInfo){
            Debug.Trace(i+" - "+MediaInfo[i]);
      }

}

function parseMedia(Media) {
      var mediaExp = /^\\0([a-z]+)\\0([0-1])\\0(.*)\\0(.*)\\0(.*)\\0(.*)\\0(.*)\\0$/i;
      if(typeof(Media) == "string" && mediaExp.test(Media)) {
            var arr = new Array();
            arr['Type'] = RegExp.$1;
            arr['Enabled'] = RegExp.$2;
            arr['Format'] = RegExp.$3;
            arr['Title'] = RegExp.$4;
            arr['Artist'] = RegExp.$5;
            arr['Album'] = RegExp.$6;
            arr['ContentId'] = RegExp.$7;
            Debug.Trace(arr);
            return arr;
      } else {
            return false;
      }
}


That works perfectly

This post was edited on 11-21-2006 at 09:53 PM by Spunky.
<Eljay> "Problems encountered: shit blew up" :zippy:
11-21-2006 09:39 PM
Profile PM Find Quote Report
roflmao456
Skinning Contest Winner
****

Avatar

Posts: 955
Reputation: 24
30 / Male / Flag
Joined: Nov 2006
Status: Away
O.P. RE: RE: how to filter the music?
quote:
Originally posted by SpunkyLoveMuff
It is an error on your part as the function works fine...

code:
var MediaInfo = new Array();

function OnEvent_MyMediaChange(NewMedia){
    MediaInfo = parseMedia(NewMedia);
    for(i in MediaInfo){
        Debug.Trace(i+" - "+MediaInfo[i]);
    }

}

function parseMedia(Media) {
    var mediaExp = /^\\0([a-z]+)\\0([0-1])\\0(.*)\\0(.*)\\0(.*)\\0(.*)\\0(.*)\\0$/i;
    if(typeof(Media) == "string" && mediaExp.test(Media)) {
        var arr = new Array();
        arr['Type'] = RegExp.$1;
        arr['Enabled'] = RegExp.$2;
        arr['Format'] = RegExp.$3;
        arr['Title'] = RegExp.$4;
        arr['Artist'] = RegExp.$5;
        arr['Album'] = RegExp.$6;
        arr['ContentId'] = RegExp.$7;
        Debug.Trace(arr);
        return arr;
    } else {
        return false;
    }
}


That works perfectly



wewt! thanks -.-
[quote]
Ultimatess6
: What a noob mod
11-21-2006 09:46 PM
Profile PM Web Find Quote Report
Spunky
Former Super Mod
*****

Avatar

Posts: 3658
Reputation: 61
36 / Male / Flag
Joined: Aug 2006
RE: how to filter the music?
Whats the point in quoting the message before you if you're not going to refer to it or make a further point? Just type a normal reply if a quote isn't needed
<Eljay> "Problems encountered: shit blew up" :zippy:
11-22-2006 12:00 AM
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