altv-js-module icon indicating copy to clipboard operation
altv-js-module copied to clipboard

Audio API alt.Audio.getOutputs() doesn't work

Open eiksch opened this issue 3 years ago • 0 comments

Description of the problem

When you want to clear every output from an alt.Audio source, you have to get every output and remove it with alt.Audio.removeOutput().

Because alt.Audio.getOutputs() does not work, you cannot get the previously set outputs.

WORKAROUND: save them in an array or map by yourself and then clear with alt.Audio.removeOutput()

Reproduction steps

  1. initialize sound let sound = new alt.Audio("https://dl.statev.de/test.ogg", 1, "hud", false);
  2. add output
let targetName = "FILL_IN_NAME";
  let p = alt.Player.all.find((p) => p.name === targetName);
  if(!p){
    return;
  }
  sound.addOutput(p.scriptID); //same behavior if I set p.scriptID or p, function accepts both apparantly
  1. remove every output set
let outputs = sound.getOutputs();
for(let o of outputs){
  sound.removeOutput(o.scriptID); //again, both, o and o.scriptID fail
}
[18:18:52][Error]           sound.removeOutput(o);
[18:18:52][Error]   Error: Argument 1 must be a Entity

Expected behaviour

that it returns every output

Additional context

Operating system

Windows 11

Version

alt:V build 11.4, branch release

Scope

client

eiksch avatar Jul 17 '22 17:07 eiksch