在Blazor中,如何预览上传到内存中的视频?

问题描述

选择了图像文件后,我设法进行了预览(使用Blazorise的FileEdit组件)。我的代码如下:

...other code
<FileEdit Changed="@OnChanged" Filter="image/*,video/mp4" />
<img src="@_imageData" style="width: 90%" />


@code{
string _imageData = String.Empty;

 async Task OnChanged(FileChangedEventArgs e)
    {
       
        try
        {
            foreach (var file in e.Files)
            {
                // A stream is going to be the destination stream we're writing to.
                using (var stream = new MemoryStream())
                {
                    // Here we're telling the FileEdit where to write the upload result
                    await file.WritetoStreamAsync(stream);

                    _imageData = $"data:image/jpg;base64,{Convert.ToBase64String(stream.ToArray())}";
                   
                }
            }
        }
        catch (Exception exc)
        {
            Console.WriteLine(exc.Message);
        }
        finally
        {
            StateHasChanged();
        }
    }
}

...other code

我认为“ _imageData = ...”部分中正在处理允许使用该文件的内存。

问题是,对于视频文件,我该如何实现?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)