View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0019300 | MMW 5 | Extensions framework | public | 2022-08-07 07:01 | 2022-09-16 22:03 |
Reporter | zvezdan | Assigned To | |||
Priority | urgent | Severity | minor | Reproducibility | N/A |
Status | closed | Resolution | fixed | ||
Product Version | 5.0.3 | ||||
Target Version | 5.0.4 | Fixed in Version | 5.0.4 | ||
Summary | 0019300: playlist/player.setTracklist() method needed | ||||
Description | The suggested method should work similarly to the tracklist.useList method, but applied directly on the playlist or player objects, i.e. it should perform clearTracksAsync and addTracksAsync methods. The problem when using combination of these two existing methods is that: 1. it causes flickering of tracks in the playlist; 2. it could lead to the incorrect data since these methods are executed asynchronously, which means that some another part of code that use the same list could be executed between these two methods. These problems happens even when these two methods are used between beginUpdate/endUpdate. | ||||
Steps To Reproduce | 1. add the attached add-on; 2. create 'ZDTest' playlist and add several tracks to it; 3. open DevTools / Console; 4. click on the add-on's toolbar button and wait -> you will see reported the number of tracks in the log that are different than the actual number of tracks in the playlist. | ||||
Additional Information | Here is the content of the init.js: var goQueueListPlaylist; var giTrackCount; window.uitools.addToolButton('righttoolbuttons', 'remove', function () { var progress = app.backgroundTasks.createNew(); app.playlists.getByTitleAsync('ZDTest').then(function(oCurPlaylist) { if (!oCurPlaylist) { ODS("ZDTest playlist doesn't exist"); return; } goQueueListPlaylist = oCurPlaylist; (function loop() { setTimeout(function() { var oQueueList = oCurPlaylist.getTracklist(); oQueueList.whenLoaded().then(function () { giTrackCount = oQueueList.count; goQueueListPlaylist.beginUpdate(); goQueueListPlaylist.clearTracksAsync().then(() => { goQueueListPlaylist.addTracksAsync(oQueueList).then(() => { goQueueListPlaylist.endUpdate(); if (!progress.terminated && !window._cleanUpCalled) { loop(); } }); }); }); }, 250); })(); (function loop() { setTimeout(function() { var goQueueList = goQueueListPlaylist.getTracklist(); goQueueList.whenLoaded().then(async () => { if (goQueueList.count != giTrackCount) { console.log('ZDTest6 - goQueueList.count: ' + goQueueList.count); } if (!progress.terminated && !window._cleanUpCalled) { loop(); } }); }, 250); })(); }); }, 'ZDTest6'); | ||||
Tags | No tags attached. | ||||
Attached Files | |||||
Fixed in build | 2663 | ||||
|
For the Playlist I introduced new function setTracksAsync (that is combination of clearTracksAsync and addTracksAsync as suggested) in build 5.0.4.2663 |
|
For the Player I have found that addTracksAsync already have the 'withClear' param that can be used to clear the Playing queue at first, see: https://www.mediamonkey.com/docs/api/classes/Player.html |
|
Verified 2662 API DOC page is at https://www.mediamonkey.com/docs/api/classes/Playlist.html#method_setTracksAsync |