Amarok2 TrackInfo object in QtScript

I just started playing with QtScript in Amarok and so far the documentation has been a big let down. A lot of things are documented for C++ but the conversion into JavaScript is a lot trickier then it looked.

This is ofcourse because the whole QtScript engine is all new and this will become better over time. In this posting I will show what the TrackInfo object holds, which is returned by Amarok.Engine.currentTrack();

 destroyed(QObject*): function () { [native] } destroyed(): function () { [native] } deleteLater(): function () { [native] } objectName:  title: Hotaka (radio edit) sampleRate: 44100 bitrate: 192 score: 49.5 rating: 0 inCollection: true type: mp3 length: 215 fileSize: 5195160 trackNumber: 1 discNumber: 0 playCount: 1 playable: true album: Hotaka artist: Juno Reactor composer:  genre: Electronic year: 2002 comment: DHA's Music Archive path: /mnt/music/Mp3/Albums2/Juno Reactor/Juno Reactor - Hotaka/01 Hotaka (radio edit).mp3 isValid: true isEditable: true lyrics: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">  <html xmlns="" xml:lang="en" lang="en" dir="ltr">  <head>      <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />      <title>Juno Reactor Hotaka (radio edit) lyrics</title>  </head>  <body><h3><a href=''>Hotaka (radio edit)</a> by <a href=''>Juno Reactor</a></h3> <pre> Not found</pre><hr/>Additional Info: <ul> <li><strong>url: </strong><a href=';action=edit' title='url'>;action=edit</a> </li> </ul> </body> </html> 

So the next time you need some information about the currently playing track you know exactly which fields are available.

On a side note: the isValid boolean tells you if the track info you are parsing is in fact a running track. If Amarok is not playing all fields will be empty or zero. Check isValid before you start processing an empty data object…

Related Post

Leave a Reply

Your email address will not be published. Required fields are marked *