最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Using mediainfo.js in Blazor Webassambly - Stack Overflow

programmeradmin0浏览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.

regards Alex

UPDATE:

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

<script src=".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);

After some more experiments, there is still no solution, but I think my problem is, that I not know how to correctly import the needed js files/modules. In the npm package there are different subfolders (esm, esm-bundle, umd) I tried all of them as entry point, but I am not shure what is the right way for my Blazor Webassambly, or even if it is possible at all.

I would be very happy to get some help, because I have no more ideas what I can try here.

发布评论

评论列表(0)

  1. 暂无评论