This snippet will let you retrieve info from media files on your computer.
The usage is the same as $sound ($sound().) but with different properties.
The properties you can use are:
album, albumartist, author, duration, filesize, filetype, genre, iscopyright, isvbr, publisher, title, track, trackingid, userlastplayedtime, userplaycount, userplaycountmorning, userplaycountafternoon, userplaycountevening, userplaycountnight, userplaycountweekday, userplaycountweekend, userrating or year.
If you specify the duration property then $wsound() will accept a second parameter to let you specify the $asctime() format the time should be returned in (eg: nn:ss for minutes:seconds).
This identifier relies heavily on windows media player (tested with the latest version (10.00.00.3646) but might work on earlier versions).
Some of the properties will only interest you if windows media player is the player you use to play your music, these are:
trackingid, userlastplayedtime, userplaycount, userplaycountmorning, userplaycountafternoon, userplaycountevening, userplaycountnight, userplaycountweekday, userplaycountweekend and userrating.
The trackingid is an ID number media player gives to each file.
The userlastplayedtime is the last time the file was played.
The userplaycount is the amount of times the file has been played all of the way through (if you play a song half way through and then stop it this number will not increment).
The userplaycountmorning is the amount of times the file has been played in the morning.
The userplaycountafternoon is the amount of times the file has been played in the afternoon.
The userplaycountevening is the amount of times the file has been played in the evening.
The userplaycountnight is the amount of times the file has been played in the night.
The userplaycountweekday is the amount of times the file has been played on a weekday.
The userplaycountweekend is the amount of times the file has been played on a weekend.
The userrating is the rating the file has been given.
alias wsound {
if (!$istok(album albumartist author duration filesize filetype genre iscopyright isvbr publisher title track trackingid userlastplayedtime userplaycount $&
userplaycountafternoon userplaycountevening userplaycountmorning userplaycountnight userplaycountweekday userplaycountweekend $&
userrating year,$prop,32)) return E_INVALID_PROPERTY
if (!$isfile($1)) return E_NO_SUCH_FILE
.comopen wmp::temp WMPlayer.OCX
if (!$com(wmp::temp)) return E_UNABLE_TO_OPEN_OBJECT
!.echo -q $com(wmp::temp,Controls,3,dispatch* wmp::temp::controls)
if (!$com(wmp::temp::controls)) {
.comclose wmp::temp
return E_UNABLE_TO_OPEN_OBJECT
}
!.echo -q $com(wmp::temp,Url,4,bstr,$1-)
!.echo -q $com(wmp::temp::controls,Stop,3)
!.echo -q $com(wmp::temp,currentMedia,3,dispatch* wmp::temp::currentmedia)
if (!$com(wmp::temp::currentmedia)) {
.comclose wmp::temp
.comclose wmp::temp::controls
return E_UNABLE_TO_OPEN_OBJECT
}
var %result = $(,,$com(wmp::temp::currentmedia,getItemInfo,3,bstr,$replace($prop,album,wm/albumtitle,albumartist,wm/albumartist,isprotected,is_protected, $&
publisher,wm/publisher,track,wm/tracknumber,year,wm/year))) $com(wmp::temp::currentmedia).result
.comclose wmp::temp
.comclose wmp::temp::controls
.comclose wmp::temp::currentmedia
if ($prop == duration) && ($2) return $asctime(%result,$2)
return %result
}
I assume that means the snippet works for you? Good :)
Some people have reported that the snippet still doesn\'t work for them, yet it works for me and several others.
The problem with using COM is that something that works on one system could outright fail on the next. As you can imagine this can be annoying sometimes!
The snippet wasn\'t working because you had to play the file to gather info from it, so I\'ve updated the snippet so that it plays and then instantly stops the file. Hopefully, even on fairly slow pcs, you shouldn\'t be able to hear the song before it stops playing, but someone tell me if you can hear it please.