- Code: Select all
Dim SDB : Set SDB = CreateObject("SongsDB5.SDBApplication")
Dim SLText : SLText = SDB.runJSCode("(function() { return app.player.getSongList().getTracklist().asJSON; })()", True)
Dim SL : Set SL = SDB.fromJSON(SLText)
Moderator: jiri
Dim SDB : Set SDB = CreateObject("SongsDB5.SDBApplication")
Dim SLText : SLText = SDB.runJSCode("(function() { return app.player.getSongList().getTracklist().asJSON; })()", True)
Dim SL : Set SL = SDB.fromJSON(SLText)
Ludek wrote:Anyhow looking into our code you seem to be right that SDBPlayList is not fully implemented, most of the code of the corresponding properties/methods is commented out.
Seems to make sense to add them, going to discuss with other devs and look into it.
PetrCBR wrote:Using code i've sent you can receive any tracklist to your COM.
PetrCBR wrote:In next build new method will be implemented
PetrCBR wrote:SDB.fromJSON (currently just SongList is supported). In JS we have asJSON property implemented for all of our classes so using SDB.runJSCode you can run any JS code from COM model and return object(s) exported as JSON string.
PetrCBR wrote:Simple example of getting current now playing tracklist using runJSCode and convert it to SongList object:
- Code: Select all
...
Barry4679 wrote:? "SDB.fromJSON (currently just SongList is supported)" ... I am not sure what this means? .. I will be able to get the tracklist of an autoplaylist?
Barry4679 wrote:? what language was his code example? ... I guessed Visual Basic ... or was it JS? ... I was meaing did he have a code sample (in that language) which obtained the contents of a specific autoplaylist
Dim SDB : Set SDB = CreateObject("SongsDB5.SDBApplication")
Dim SLText : SLText = SDB.runJSCode("(function() { app.playlists.getByIDAsync(3).then(function(playlist) { playlist.getTracklist().whenLoaded().then(function (list) { runJSCode_callback(list.asJSON); }); }); })()", True)
Dim SL : Set SL = SDB.fromJSON(SLText)
Barry4679 wrote:? the new method is available in 2088, or the next build?
PetrCBR wrote:Using that method you can run any JS code and as you can see from my example you can receive data as JSON string you can handle later in code. For new release (2090) i've added method runJSCode_callback so user can run more complex code and call this method to return value to COM model. For example i have playlist with ID 3 (predefined 'Accesible tracks' playlist) and i want to retrive his tracklist:
- Code: Select all
Dim SDB : Set SDB = CreateObject("SongsDB5.SDBApplication")
Dim SLText : SLText = SDB.runJSCode("(function() { app.playlists.getByIDAsync(3).then(function(playlist) { playlist.getTracklist().whenLoaded().then(function (list) { runJSCode_callback(list.asJSON); }); }); })()", True)
Dim SL : Set SL = SDB.fromJSON(SLText)
PetrCBR wrote:It was just example how to get tracks using COM as you've requested (example is in VBS as i'm not using python). I'm using PrimalScript for VBS, but it's paid application so try to look for any free app with ability to run VBS.
import win32com.client
import pythoncom
SDB = win32com.client.Dispatch("SongsDB5.SDBApplication")
x = SDB.runJScode("(function() { app.playlists.getByIDAsync(3).then(function(playlist) { playlist.getTracklist().whenLoaded().then(function (list) { runJSCode_callback(list.asJSON); }); }); })()", True)
PetrCBR wrote:My code require 2090 or later and it was tested (it's using async result using runJSCode_callback and it was implemented in 2090).
Dim SDB : Set SDB = CreateObject("SongsDB5.SDBApplication")
Dim SLText : SLText = SDB.runJSCode("(function() { app.playlists.getByIDAsync(3).then(function(playlist) { playlist.getTracklist().whenLoaded().then(function (list) { runJSCode_callback(list.asJSON); }); }); })()", True)
Dim SL : Set SL = SDB.fromJSON(SLText)
SDB.runJSCode("(function() { app.getIniFile().then(function(iniFileAccess) { iniFileAccess.getStringValue('System','DBName') }); }); ()", True)
Barry4679 wrote:While I am waiting would you mind posting an example JSON string from your List.asJSON callback in the above example code?
"{"_persistentID":"SharedList","objectType":"playlistentries", "data":[{"_persistentID":"153687","objectType":"playlistentry", {"_persistentID":"153686","objectType":"playlistentry"]}"
Barry4679 wrote:what type is SDB in that example? I don't see the runJSCode method documented here: http://www.mediamonkey.com/webhelp/MM5P ... s/App.html
I looked in App and DB, as I thought it may be there ..?
Barry4679 wrote:Which is the part that is not coming until 2089?
Barry4679 wrote:
- Code: Select all
SDB.runJSCode("(function() { app.getIniFile().then(function(iniFileAccess) { iniFileAccess.getStringValue('System','DBName') }); })()", True)
SDB.runJSCode("(function() { app.getIniFile().then(function(iniFileAccess) { runJSCode_callback(iniFileAccess.getStringValue('System','DBName')) }); })()", True)
Barry4679 wrote:I followed the advice from the sticky thread, and opened the Chromium Developer Tools console. ... It doesn't look like this is going to me much help when debugging something via COM ... ie. I see that I have an unexpected token, but I can't see inside any of the source modules, to see what token, and where. .. should I be able to see inside them? How do you recommend testing a COM called runJSCode function?
SDB.runJSCode("(function() { ... anything NON async i need to do .... return result; })()", True)
Users browsing this forum: No registered users and 1 guest