如何解决在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 举报,一经查实,本站将立刻删除。