Quantcast
Channel: Active questions tagged blazor - Stack Overflow
Viewing all articles
Browse latest Browse all 4839

Using mediainfo.js in Blazor Webassambly

$
0
0

I am trying to use mediainfo.js in my Blazor Webassambly App.Using JS in this context is new to me, so I am not shure how to deal with this.Calling javascript functions out of my c# code is not the problem, but if I try to use some mediainfo part inside of my own javascript function, I get errors.

I tried different ways to import the madiainfo.js library to may project: as File, over CDN,...But every time it seems that it could not be found if I try to use it.

Maybe someone can give me a small example how to use it.

regardsAlex

UPDATE:

Here is what I am doning at the moment:at index.html I have this lines:

<script src="https://cdn.jsdelivr.net/npm/mediainfo.js/dist/mediainfo.js"></script><script src="mediainfo-wrapper.js"></script>

my mediainfo-wrapper.js is this:

async function getMediaInfo(file) {    const mediaInfoInstance = await MediaInfo({ format: 'object' });    const fileData = await file.arrayBuffer();    const result = await mediaInfoInstance.analyzeData(() => file.size, () => fileData);    return result;}

and with this line I call the JS function from my Blazor code:

await JSRuntime.InvokeAsync<string>("getMediaInfo", file);

Viewing all articles
Browse latest Browse all 4839

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>