public AlphaTabWorkerScoreRenderer(AlphaTabApi api, Settings settings) { _api = api; try { _worker = new Worker(settings.ScriptFile); } catch { // fallback to blob worker try { HaxeString script = "importScripts('" + settings.ScriptFile + "')"; var blob = new Blob(new [] { script }); _worker = new Worker(URL.CreateObjectURL(blob)); } catch (Exception e) { Logger.Error("Rendering", "Failed to create WebWorker: " + e); // TODO: fallback to synchronous mode } } _worker.PostMessage(new { cmd = "alphaTab.initialize", settings = settings.ToJson() }); _worker.AddEventListener("message", (Action <Event>)(HandleWorkerMessage)); }
public AlphaSynthWebWorkerApi(ISynthOutput player, string alphaSynthScriptFile, LogLevel logLevel) { _output = player; _output.Ready += OnOutputReady; _output.SamplesPlayed += OnOutputSamplesPlayed; _output.SampleRequest += OnOutputSampleRequest; _output.Finished += OnOutputFinished; _events = new FastDictionary <string, FastList <Delegate> >(); _output.Open(); try { _synth = new Worker(alphaSynthScriptFile); } catch { // fallback to blob worker try { HaxeString script = "importScripts('" + alphaSynthScriptFile + "')"; var blob = new Blob(Script.Write <object>("[ script ]")); _synth = new Worker(URL.CreateObjectURL(blob)); } catch (Exception e) { Logger.Error("AlphaSynth", "Failed to create WebWorker: " + e); // TODO: fallback to synchronous mode } } _synth.AddEventListener("message", (Action <MessageEvent>)HandleWorkerMessage, false); _synth.PostMessage(new { cmd = AlphaSynthWebWorker.CmdInitialize, sampleRate = _output.SampleRate, logLevel = logLevel }); MasterVolume = 1; PlaybackSpeed = 1; MetronomeVolume = 0; }
public extern Element GetElementById(HaxeString id);
public extern UIEvent(HaxeString type, dynamic eventInitDict);
public extern void Write(HaxeString s);
public extern void FillText(HaxeString text, HaxeFloat x, HaxeFloat y);
public extern object GetContext(HaxeString contextId);
public static extern dynamic Parse(HaxeString text);
[Name("removeEventListener")] public extern void RemoveEventListener(HaxeString type, EventListener listener);
public extern HTMLCollection GetElementsByClassName(HaxeString className);
public extern NodeList QuerySelectorAll(HaxeString selectors);
public extern Element QuerySelector(HaxeString selectors);
public extern Event CreateEvent(HaxeString interface_);
public extern HTMLCollection GetElementsByTagName(HaxeString localName);
public extern Element CreateElement(HaxeString localName);
[Name("addEventListener")] public extern void AddEventListener(HaxeString type, Delegate listener);
[Name("addEventListener")] public extern void AddEventListener(HaxeString type, Delegate listener, HaxeBool capture, bool wantsUntrusted);
public extern void SetAttribute(HaxeString name, HaxeString value);
[Name("removeEventListener")] public extern void RemoveEventListener(HaxeString type, Delegate listener, HaxeBool capture);
public extern Attr GetNamedItem(HaxeString name);
public extern Window Open(HaxeString url, HaxeString target, HaxeString features);
public extern void Add(HaxeString token);
public extern TextDecoder(HaxeString label);
public extern void Remove(HaxeString token);
public extern TextMetrics MeasureText(HaxeString text);
public extern Worker(HaxeString worker);
public extern Node CreateTextNode(HaxeString text);
[Name("addEventListener")] public extern void AddEventListener(HaxeString type, EventListener listener, HaxeBool capture);
public extern MessageEvent(HaxeString type, dynamic eventInitDict);
[Name("initEvent")] public extern void InitEvent(HaxeString type, HaxeBool bubbles, HaxeBool cancelable);