Update Play Sound module

This commit is contained in:
Brendan Coles
2016-05-05 13:59:00 +00:00
parent 3af579bcd5
commit 4aa5a87908
2 changed files with 21 additions and 28 deletions

View File

@@ -5,32 +5,14 @@
//
beef.execute(function() {
function playSound(url) {
function createSound(which) {
window.soundEmbed = document.createElement("audio");
window.soundEmbed.setAttribute("src", which);
window.soundEmbed.setAttribute("style", "display: none;");
window.soundEmbed.setAttribute("autoplay", true);
}
if (!window.soundEmbed) {
createSound(url);
}
else {
document.body.removeChild(window.soundEmbed);
window.soundEmbed.removed = true;
window.soundEmbed = null;
createSound(url);
}
window.soundEmbed.removed = false;
document.body.appendChild(window.soundEmbed);
}
playSound("<%== @sound_file_uri %>");
beef.net.send("<%= @command_url %>", <%= @command_id %>, "Sound Played");
var url = "<%== @sound_file_uri %>";
try {
var sound = new Audio(url);
sound.play();
beef.debug("[Play Sound] Played sound successfully: " + url);
beef.net.send("<%= @command_url %>", <%= @command_id %>, "result=Sound Played", beef.are.status_success());
} catch (e) {
beef.debug("[Play Sound] HTML5 audio unsupported. Could not play: " + url);
beef.net.send("<%= @command_url %>", <%= @command_id %>, "fail=audio not supported", beef.are.status_error());
}
});

View File

@@ -11,5 +11,16 @@ beef:
name: "Play Sound"
description: "Play a sound on the hooked browser."
authors: ["Saafan"]
# http://caniuse.com/audio
target:
working: ["All"]
not_working:
IE:
min_ver: 1
max_ver: 8
FF:
min_ver: 1
max_ver: 2
S:
min_ver: 1
max_ver: 3