Is it possible to enable/disable Blockly sounds in runtime?

238 views
Skip to first unread message

Guilherme Recchi Cardozo

unread,
Aug 28, 2017, 2:29:12 PM8/28/17
to Blockly
Is there an option to enable/disable Blockly sounds (delete and click) after the Blockly injection?

Neil Fraser

unread,
Aug 28, 2017, 3:09:46 PM8/28/17
to blo...@googlegroups.com
Monkey patching!

var silence = true;
var realPlay = Blockly.WorkspaceAudio.prototype.play;
Blockly.WorkspaceAudio.prototype.play = function(name, opt_volume) {
  if (!silence) {
    realPlay(name, opt_volume);
  }
};

On 28 August 2017 at 19:29, Guilherme Recchi Cardozo <gcar...@inf.ufsm.br> wrote:
Is there an option to enable/disable Blockly sounds (delete and click) after the Blockly injection?

--
You received this message because you are subscribed to the Google Groups "Blockly" group.
To unsubscribe from this group and stop receiving emails from it, send an email to blockly+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--

Neil Fraser

unread,
Aug 28, 2017, 3:14:40 PM8/28/17
to blo...@googlegroups.com
Er, I think you'll need to use .call() since 'this' must be specified:

  realPlay.call(this, name, opt_volume);

Guilherme Recchi Cardozo

unread,
Sep 6, 2017, 7:58:44 AM9/6/17
to Blockly, ro...@neil.fraser.name
Thank you, Neil! 


Em segunda-feira, 28 de agosto de 2017 16:14:40 UTC-3, Neil Fraser escreveu:
Er, I think you'll need to use .call() since 'this' must be specified:

  realPlay.call(this, name, opt_volume);
On 28 August 2017 at 20:09, Neil Fraser <ro...@neil.fraser.name> wrote:
Monkey patching!

var silence = true;
var realPlay = Blockly.WorkspaceAudio.prototype.play;
Blockly.WorkspaceAudio.prototype.play = function(name, opt_volume) {
  if (!silence) {
    realPlay(name, opt_volume);
  }
};
On 28 August 2017 at 19:29, Guilherme Recchi Cardozo <gcar...@inf.ufsm.br> wrote:
Is there an option to enable/disable Blockly sounds (delete and click) after the Blockly injection?

--
You received this message because you are subscribed to the Google Groups "Blockly" group.
To unsubscribe from this group and stop receiving emails from it, send an email to blockly+u...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages