Registered Member
|
Hello everybody,
I am just trying to create a simple amarok script. But I don't know (and I don't succeed in finding) how to : - get the path of the current track - create a folder (if possible) For the first point, I know I can get the current track by using : Amarok.Engine.currentTrack() I saw on Amarok development page that we can get the current track artist like that : Amarok.Engine.currentTrack().artist But I don't know which argument could give me the fullpath. For the second point, I just don't know where to find the function to create a folder (I am quite a beginer in QT). Thanks in advance for your help ! |
KDE Developer
|
I'm not familiar with the QtScript bindings, but a quick look at the code says the file path should be the 'url' property.
Creating a folder would be QDir().mkdir(path) or .mkpath(path). |
Registered Member
|
Ok thanks for your answer.
When you say "a quick look to the code" which code do you mean ? I don't know where to search. |
Registered Member
|
Do I have to import something to use QDir() ?
When I try to run the script it crashes and give the output : "QDir() : did you forget to construct with new" Currently I have the following imports : Importer.loadQtBinding("qt.core"); Importer.loadQtBinding("qt.gui"); Importer.loadQtBinding("qt.network"); Importer.loadQtBinding("qt.core.QDir"); And I try to run the code : if(QDir().exists(new_path)) Amarok.alert("exists: " + new_path); else Amarok.alert("doesn't exist: " + new_path); Thanks for your help ! |
KDE Developer
|
As the error suggests, you're missing the new keyword, which is used for object creation in JavaScript (technically, ECMAScript).
I strongly suggest reading some basic JavaScript tutorials. |
Registered Member
|
Thanks, it works perfectly !
Just one comment, "Amarok.Engine.currentTrack().url" was returning me the path of the track with "%20" instead of spaces. I found the following command which suits me more :
|
Registered users: Bing [Bot], Evergrowing, Google [Bot], Sogou [Bot]