This snippet will let you retrieve info from media files on your computer.<br>
The usage is the same as $sound ($sound(<file>).<property>) but with different properties.<br>
The properties you can use are:<br><br>
album, albumartist, author, duration, filesize, filetype, genre, iscopyright, isvbr, publisher, title, track, trackingid, userlastplayedtime, userplaycount, userplaycountmorning, userplaycountafternoon, userplaycountevening, userplaycountnight, userplaycountweekday, userplaycountweekend, userrating or year.<br><br>
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).<br><br>
This identifier relies heavily on windows media player (tested with the latest version (10.00.00.3646) but might work on earlier versions).<br><br>
Some of the properties will only interest you if windows media player is the player you use to play your music, these are:<br><br>
trackingid, userlastplayedtime, userplaycount, userplaycountmorning, userplaycountafternoon, userplaycountevening, userplaycountnight, userplaycountweekday, userplaycountweekend and userrating.<br><br>
The trackingid is an ID number media player gives to each file.<br>
The userlastplayedtime is the last time the file was played.<br>
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).<br>
The userplaycountmorning is the amount of times the file has been played in the morning.<br>
The userplaycountafternoon is the amount of times the file has been played in the afternoon.<br>
The userplaycountevening is the amount of times the file has been played in the evening.<br>
The userplaycountnight is the amount of times the file has been played in the night.<br>
The userplaycountweekday is the amount of times the file has been played on a weekday.<br>
The userplaycountweekend is the amount of times the file has been played on a weekend.<br>
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
}