Dear mgpai,
thank you very much for your effort!
Unfortunately I did not get your script to work. The player opens only if the script is triggered from a package ... but not if triggered from a single file. But the opened player does not play the file for unknown (to me) reasons.
I managed to combine two of your earlier scripts for me (originally for separate purposes) ... and this comes pretty close: the player plays when triggered from a package and also when triggered from a single file. The only drawback: If the package contains more than one file, it opens many players (instead of putting them in a single playlist.)
As a workaround: Can you give me a hint, how to exit the loop, when the first file to play has been found? (So the playlist won't be filled, but at least I don't have a ton of open players.)
Code:
if (name == "Play") {
var links = dlSelection.getLinks();
if (links.length) {
links.forEach(function(link) {
var player = "/usr/bin/smplayer"; // <- Set path to media player
var file = getPath(link.getDownloadPath());
if (file.exists()) {
callAsync(null, player, file);
} else {
var partFile = getPath(file + ".part");
if (partFile.exists()) {
callAsync(null, player, partFile);
}
}
})
}
}