FANDOM


The built-in play() function has some limitations on the Windows platform. Specifically, it is unable to handle filenames that are longer than 127 character, and it cannot play more than one sound at a time.

The playBetter() function below is designed to address these issues. Just include this function in your widget's onLoad JavaScript, and use playBetter() instead of any play() calls you may have.

function playBetter(path, truncate)
{
  switch (system.platform) {
    case "windows":
      if (!playBetter.bObjs)
        playBetter.bObjs = new Array();
      if (truncate) {
        for (var i = 0; i < playBetter.bObjs.length; i++)
          playBetter.bObjs[i].controls.stop();
      }
      if (path) {
        for (var i = 0; i <= playBetter.bObjs.length; i++) {
          if (i == playBetter.bObjs.length)
            playBetter.bObjs.push(COM.createObject("WMPlayer.OCX.7"));
          var playState = playBetter.bObjs[i].playState;
          if (playState == 3 || playState == 6)
            continue;
          playBetter.bObjs[i].URL = path;
          playBetter.bObjs[i].controls.play();
          break;
        }
      }
      break;
    default:
      play(path, truncate);
      break;
  }
}


Advanced useEdit

By default, playBetter creates as few unique instances of a Windows Media Player COM object as are necessary to play all the sound files requested.

Be careful not to call playBetter in a tight loop - if many sounds are playing simultaneously, your widget will use a lot of memory, because each instance requires its own chunk of memory.

To stop all currently playing sounds, you can make the following call:

playBetter("", true);


TroubleshootingEdit

Konfabulator may report the following error when using this on some Windows PCs:

uncaught exception: Unable to create object: The specified module could not be found.

This is caused by Windows Media Player DLLs not being properly registered. To fix it, simply run the following two commands:

regsvr32.exe wmp.dll
regsvr32.exe wmpdxm.dll

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.