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();
}