View Single Post
  #1508  
Old 18.08.2020, 22:56
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,003
Default

Quote:
Originally Posted by Dockel View Post
... sound to be played when a special download is downloaded completely ...
Toggle sound notification for selected (single) link/package (common script for download/linkgrabber tab):
Code:
//Toggle sound notification
//Trigger : Downloadlist Contextmenu Button Pressed AND/OR Linkgrabber Contextmenu Button Pressed
//Customize context menu > Create a new "Eventscripter trigger" button > Rename it to "Toggle sound notification" > Change Icon (optional)

if (name == "Toggle sound notification") {
    var dlSelection, lgSelection;
    var selection = dlSelection || lgSelection;

    if (selection) {
        var obj = selection.getContextPackage() || selection.getContextLink();
        var comment = obj.comment || "";
        var myComment = selection.isPackageContext() ? "#playsoundwhenpackagefinished#" : "#playsoundwhenlinkfinished#";

        if (comment.indexOf(myComment) > -1) {
            obj.comment = comment.replace(myComment, "");
        } else {
            obj.comment = myComment + comment;
        }
    }
}

Play sound notification for marked link/package:
Code:
//Play sound when download finished
//Trigger: A Download Stopped

var notify, myWavFile = JD_HOME + "/themes/standard/org/jdownloader/sounds/captcha.wav"; // <- Specify path to 'wav' file

if (link.finished) {
    var comment = link.comment || "";
    var myComment = "#playsoundwhenlinkfinished#";

    if (comment.indexOf(myComment) > -1) {
        link.comment = comment.replace(myComment, "");
        notify = true;
    }
}

if (package.finished) {
    var comment = package.comment || "";
    var myComment = "#playsoundwhenpackagefinished#";

    if (comment.indexOf(myComment) > -1) {
        package.comment = comment.replace(myComment, "");
        notify = true;
    }
}

if (notify) {
    playWavAudio(myWavFile);
}

Last edited by mgpai; 24.08.2020 at 13:10. Reason: Fixed incorrect context menu item name case in script comment
Reply With Quote