Com.Netease.VCloud.AspNetCore
1.0.4
dotnet add package Com.Netease.VCloud.AspNetCore --version 1.0.4
NuGet\Install-Package Com.Netease.VCloud.AspNetCore -Version 1.0.4
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Com.Netease.VCloud.AspNetCore" Version="1.0.4" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Com.Netease.VCloud.AspNetCore --version 1.0.4
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Com.Netease.VCloud.AspNetCore, 1.0.4"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Com.Netease.VCloud.AspNetCore as a Cake Addin
#addin nuget:?package=Com.Netease.VCloud.AspNetCore&version=1.0.4
// Install Com.Netease.VCloud.AspNetCore as a Cake Tool
#tool nuget:?package=Com.Netease.VCloud.AspNetCore&version=1.0.4
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
网易云信点播 SDK
简介
通过查阅网易云信官方文档:https://doc.yunxin.163.com/, 基于网易云信点播媒体上传官方SDK进行改造,升级为.NET 6 运行时, 注册到Asp.Net Core DI容器,利用IHttpClientFactory管理HttpClient的生命周期, 详细功能介绍请查看:https://doc.yunxin.163.com/docs/jY3NDM4Nzc/jI0Njk0NzU, 源代码仓库地址:https://gitee.com/tanwucheng/Com.Netease.VCloud.Core.git
使用示例
// Program.cs启动文件注册
using Com.Netease.VCloud.AspNetCore;
var builder = WebApplication.CreateBuilder(args);
// 其他代码 省略...
// 注册LiveVCloudClient
var appKey = "???";
var appSecret = "???";
builder.Services.AddNeteaseVCloudClient(options =>
{
options.AppKey = appKey;
options.AppSecret = appSecret;
});
// 其他代码 省略...
app.Run();
// 控制器注入使用
/// <summary>
/// 网易云信点播数据接口
/// </summary>
[ApiController]
[Route("[controller]")]
public class VCloudController : ControllerBase
{
private readonly IVCloudClient _client;
private readonly ILogger<LiveVCloudController> _logger;
/// <summary>
/// VCloudController
/// </summary>
/// <param name="client"></param>
public VCloudController(IVCloudClient client, ILogger<LiveVCloudController> logger)
{
_client = client;
_logger = logger;
}
/// <summary>
/// 上传文件
/// </summary>
/// <param name="file"></param>
/// <returns></returns>
[HttpPost("upload")]
public async Task<QueryVideoIDorWatermarkIdParam?> UploadVideo(IFormFile file)
{
try
{
var mime = MimeTypesMap.GetMimeType(file.FileName);
if (mime.IndexOf("video", StringComparison.Ordinal) < 0) throw new Exception("请上传合法的视频文件!");
var stream = file.OpenReadStream();
IDictionary<string, object> initParamMap = new Dictionary<string, object>
{
{ "originFileName", file.FileName }
};
var param = await _client.UploadVideoAsync(stream, stream.Length, initParamMap);
return param;
}
catch (Exception e)
{
_logger.LogError(e.Message);
return new QueryVideoIDorWatermarkIdParam { Code = HttpStatusCode.BadRequest.GetHashCode(), Msg = e.Message };
}
}
/// <summary>
/// 获取视频文件信息
/// </summary>
/// <param name="vid"></param>
/// <returns></returns>
[HttpGet("{vid:long}")]
public async Task<CommonResponse<GetVideoRet>?> GetVideo(long vid)
{
try
{
var response = await _client.GetVideoAsync(vid);
return response;
}
catch (Exception e)
{
_logger.LogError(e.Message);
return new CommonResponse<GetVideoRet> { Code = VCloudStatusCode.BadRequest, Msg = e.Message };
}
}
/// <summary>
/// 设置回调地址
/// </summary>
/// <param name="type">回调地址类型,1表示转码回调,2表示上传回调,5表示视频合并回调,6表示视频裁剪回调</param>
/// <param name="callbackUrl">处理完成后回调的URL地址(需标准http格式,长度不超过200)</param>
/// <returns></returns>
[HttpGet("setCallbackUrl")]
public async Task<CommonResponse<RetBase>?> SetCallbackUrl(int type, string callbackUrl)
{
try
{
var response = await _client.SetCallbackUrlAsync(new SetCallbackUrlRequest
{ Type = type, CallbackUrl = callbackUrl });
return response;
}
catch (Exception e)
{
_logger.LogError(e.Message);
return new CommonResponse<RetBase> { Code = VCloudStatusCode.BadRequest, Msg = e.Message };
}
}
/// <summary>
/// 查询回调地址
/// </summary>
/// <param name="type">回调地址类型,1表示转码回调,2表示上传回调,5表示视频合并回调,6表示视频裁剪回调</param>
/// <returns></returns>
[HttpGet("getCallbackUrl/{type:int}")]
public async Task<CommonResponse<GetVCloudCallbackUrlRet>?> GetCallbackUrl(int type)
{
try
{
var response = await _client.GetCallbackUrlAsync(type);
return response;
}
catch (Exception e)
{
_logger.LogError(e.Message);
return new CommonResponse<GetVCloudCallbackUrlRet> { Code = VCloudStatusCode.BadRequest, Msg = e.Message };
}
}
}
更新日志
- 1.0.10: Update to .NET 8
- 1.0.3: 错误修改
- 1.0.2: 错误修改
- 1.0.1: 基于Com.Netease.VCloud.Core项目改造
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net6.0
- Microsoft.Extensions.DependencyInjection (>= 8.0.0)
- Microsoft.Extensions.Http (>= 8.0.0)
- Newtonsoft.Json (>= 13.0.3)
-
net8.0
- Microsoft.Extensions.DependencyInjection (>= 8.0.0)
- Microsoft.Extensions.Http (>= 8.0.0)
- Newtonsoft.Json (>= 13.0.3)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.