Exemplo n.º 1
0
        public async ValueTask <MediaStreamTrack> Clone()
        {
            var objRef = await JsRuntime.InvokeInstanceMethodGetRef(JsObjectRef, "clone")
                         .ConfigureAwait(false);

            var obj = await JsRuntime.GetInstanceContent <MediaStreamTrack>(objRef, SerializationSpec)
                      .ConfigureAwait(false);

            obj.SetJsRuntime(JsRuntime, objRef);
            return(obj);
        }
Exemplo n.º 2
0
 /// <summary>
 /// queues a function to be called during a browser's idle periods. This enables developers to perform background and low priority work on the main event loop, without impacting latency-critical events such as animation and input response.
 /// </summary>
 /// <param name="callback">ells the browser that you wish to perform an animation and requests that the browser calls a specified function to update an animation before the next repaint. The method takes a callback as an argument to be invoked before the repaint.</param>
 /// <param name="options">Contains optional configuration parameters. Currently only one property is defined : timeout. If timeout is specified and has a positive value, and the callback has not already been called by the time timeout milliseconds have passed, the callback will be called during the next idle period, even if doing so risks causing a negative performance impact.
 /// </param>
 /// <returns>The request ID, can be used for cancelling it</returns>
 public async ValueTask <int> RequestIdleCallback(Func <IdleDeadline, ValueTask> callback,
                                                  RequestIdleCallbackOptions options = null)
 {
     return(await JsRuntime.InvokeInstanceMethod <int>(JsObjectRef, "requestIdleCallback",
                                                       CallBackInteropWrapper.Create <JsRuntimeObjectRef>(async jsRef =>
     {
         var idleDeadline = await JsRuntime.GetInstanceContent <IdleDeadline>(jsRef, true);
         idleDeadline.SetJsRuntime(JsRuntime, jsRef);
         await callback.Invoke(idleDeadline);
     }, getJsObjectRef: true), options));
 }
Exemplo n.º 3
0
        /// <summary>
        /// loads the specified resource into the browsing context (window, &lt;iframe&gt; or tab) with the specified name. If the name doesn't exist, then a new window is opened and the specified resource is loaded into its browsing context.
        /// </summary>
        /// <param name="url">URL of the resource to be loaded. This can be a path or URL to an HTML page, image file, or any other resource which is supported by the browser. If the empty string ("") is specified as url, a blank page is opened into the targeted browsing context.</param>
        /// <param name="windowName">the name of the browsing context (window,  &lt;iframe&gt; or tab) into which to load the specified resource; if the name doesn't indicate an existing context, a new window is created and is given the name specified by windowName.</param>
        /// <param name="windowFeature">comma-separated list of window features given with their corresponding values in the form "name=value". These features include options such as the window's default size and position, whether or not to include scroll bars, and so forth. There must be no whitespace in the string.</param>
        /// <returns></returns>
        public async ValueTask <WindowInterop> Open(Uri url, string windowName  = null,
                                                    WindowFeature windowFeature = null)
        {
            var windowOpenRef = await JsRuntime.InvokeInstanceMethodGetRef(JsObjectRef, "open", url, windowName,
                                                                           windowFeature?.GetOpenString());

            var windowInterop = await JsRuntime.GetInstanceContent <WindowInterop>(windowOpenRef, SerializationSpec);

            windowInterop.SetJsRuntime(JsRuntime, windowOpenRef);
            return(windowInterop);
        }
Exemplo n.º 4
0
 public async ValueTask <IAsyncDisposable> OnStorage(Func <StorageEvent, ValueTask> callback)
 {
     return(await JsRuntime.AddEventListener(JsObjectRef, "", "storage",
                                             CallBackInteropWrapper.Create <JsRuntimeObjectRef>(
                                                 async jsObject =>
     {
         var eventContent = await JsRuntime.GetInstanceContent <StorageEvent>(jsObject,
                                                                              new { key = true, oldValue = true, newValue = true, url = true });
         eventContent.Storage = new WindowStorage(JsRuntime,
                                                  await JsRuntime.GetInstancePropertyRef(jsObject, "storageArea"));
         await callback(eventContent);
     },
                                                 getJsObjectRef: true
                                                 )
                                             ));
 }