public AlphaSynthApi(string alphaSynthScriptFile = "") { // var swf = SwfObject; var supportsWebAudio = Platform.Platform.SupportsWebAudio; var supportsWebWorkers = Platform.Platform.SupportsWebWorkers; var forceFlash = Platform.Platform.ForceFlash; // explicitly specified file/root path if (!string.IsNullOrEmpty(alphaSynthScriptFile)) { // append script name if (!alphaSynthScriptFile.EndsWith(".js")) { if (!alphaSynthScriptFile.EndsWith("/")) { alphaSynthScriptFile += "/"; } alphaSynthScriptFile += "AlphaSynth.js"; } if (!alphaSynthScriptFile.StartsWith("http") && !alphaSynthScriptFile.StartsWith("https")) { var root = new StringBuilder(); root.Append(window.location.protocol); root.Append("//"); root.Append(window.location.hostname); if (window.location.port.As<bool>()) { root.Append(":"); root.Append(window.location.port); } root.Append(alphaSynthScriptFile); alphaSynthScriptFile = root.ToString(); } } // find automatically else { alphaSynthScriptFile = Platform.Platform.ScriptFile; } if (supportsWebAudio && !forceFlash) { Logger.Info("Will use webworkers for synthesizing and web audio api for playback"); RealInstance = new AlphaSynthWebWorkerApi(alphaSynthScriptFile); } else if (supportsWebWorkers) { Logger.Info("Will use webworkers for synthesizing and flash for playback"); RealInstance = new AlphaSynthFlashPlayerApi(alphaSynthScriptFile); } else { Logger.Error("Incompatible browser"); throw new Exception("Incompatible browser"); } RealInstance.Startup(); }
public AlphaSynthApi(string asRoot = "", string swfObjectRoot = "") { // var swf = SwfObject; var supportsWebAudio = SupportsWebAudio; var supportsWebWorkers = SupportsWebWorkers; var forceFlash = ForceFlash; if (asRoot == "") { asRoot = window["AsRoot"].toString(); } if (swfObjectRoot == "") { swfObjectRoot = window["SwfObjectRoot"].toString(); } if (string.IsNullOrEmpty(swfObjectRoot)) { swfObjectRoot = asRoot; } if (supportsWebAudio && !forceFlash) { Logger.Info("Will use webworkers for synthesizing and web audio api for playback"); RealInstance = new AlphaSynthWebWorkerApi(asRoot); } else if (supportsWebWorkers) { Logger.Info("Will use webworkers for synthesizing and flash for playback"); RealInstance = new AlphaSynthFlashPlayerApi(asRoot, swfObjectRoot); } else { Logger.Error("Incompatible browser"); throw new Exception("Incompatible browser"); } RealInstance.Startup(); }