/*:
* @plugindesc V1.00 Fix to JavaHut_AudioManagerEx.js
* @author OcRam (free to use commercial/personal - free to edit)
*
* @Help Place this plugin AFTER JavaHut_AudioManagerEx.js
*
*/

var Imported = Imported || {};
Imported.OcRam_JHFix = true;
var OcRam_JHFix = OcRam_JHFix || {};

(function ($) {
	// Fix to JavaHut's AudioManagerEx plugin
	AudioManager.playBgm = function (bgm, pos) {
		if (this.isCurrentBgm(bgm)) {
			this.updateBgmParameters(bgm);
		} else {
			this.stopBgm();
			if (bgm.name) {
				if (Decrypter.hasEncryptedAudio && this.shouldUseHtml5Audio()) {
					this.playEncryptedBgm(bgm, pos);
				} else {
					this._bgmBuffer = this.createBuffer('bgm', bgm.name);
					this.updateBgmParameters(bgm);
					if (!this._meBuffer) {
						this._bgmBuffer.play(true, pos || 0);
					}
				}
			}
		}
		this.updateCurrentBgm(bgm, pos);
	};
})(OcRam_JHFix);
