zoukankan      html  css  js  c++  java
  • C#对接阿里云视频模块

            public static DefaultAcsClient InitVodClient()
            {
                String accessKeyId =";//用于标识用户
                String accessKeySecret = "";//用户用于加密签名字符串和VOD用来验证签名字符串的密钥
                // 构建一个 Client,用于发起请求
                string regionId = "cn-shanghai"; //目前仅支持cn-shanghai
                IClientProfile profile = Aliyun.Acs.Core.Profile.DefaultProfile.GetProfile(regionId, accessKeyId, accessKeySecret);
                return new DefaultAcsClient(profile);
            } 
         public VideoRequest CreateUploadVideo(string strTitle, string strFileName) { CreateUploadVideoRequest request = new CreateUploadVideoRequest(); request.FileName = strFileName; request.Title = strTitle; DefaultAcsClient client = InitVodClient(); CreateUploadVideoResponse response = client.GetAcsResponse(request); VideoRequest obj = new VideoRequest(); obj.RequestId= response.RequestId; obj.UploadAddress= response.UploadAddress; obj.UploadAuth = response.UploadAuth; obj.VideoId = response.VideoId; return obj; } public void GetVideoStatis(string strVid) { DescribePlayVideoStatisRequest request = new DescribePlayVideoStatisRequest(); request.StartTime = ""; request.EndTime = ""; request.VideoId = ""; DefaultAcsClient client = InitVodClient(); DescribePlayVideoStatisResponse response = client.GetAcsResponse(request); } public string GetPlayInfo(string strVid) { try { GetPlayInfoRequest request = new GetPlayInfoRequest(); string strAliVid = this.GetAliVid(strVid); if (string.IsNullOrEmpty(strAliVid)) { return string.Empty; } request.VideoId = strAliVid; DefaultAcsClient client = InitVodClient(); GetPlayInfoResponse response = client.GetAcsResponse(request); List<GetPlayInfoResponse.GetPlayInfo_PlayInfo> playInfoList = response.PlayInfoList; if (playInfoList.Count > 0) { return playInfoList[0].PlayURL; } return string.Empty; } catch (Exception ex) { return string.Empty; throw; } } public string GetHRPlayInfo(string strVid) { try { GetPlayInfoRequest request = new GetPlayInfoRequest(); request.VideoId = strVid; DefaultAcsClient client = InitVodClient(); GetPlayInfoResponse response = client.GetAcsResponse(request); List<GetPlayInfoResponse.GetPlayInfo_PlayInfo> playInfoList = response.PlayInfoList; if (playInfoList.Count > 0) { return playInfoList[0].PlayURL; } return string.Empty; } catch (Exception ex) { return string.Empty; throw; } } public Dictionary<string,string> GetVideoDefinition(string strVid) { try { GetPlayInfoRequest request = new GetPlayInfoRequest(); Dictionary<string, string> dic = new Dictionary<string, string>(); string strAliVid = this.GetAliVid(strVid); if (string.IsNullOrEmpty(strAliVid)) { return null; } request.VideoId = strAliVid; DefaultAcsClient client = InitVodClient(); GetPlayInfoResponse response = client.GetAcsResponse(request); List<GetPlayInfoResponse.GetPlayInfo_PlayInfo> playInfoList = response.PlayInfoList; if (playInfoList.Count > 0) { foreach (GetPlayInfoResponse.GetPlayInfo_PlayInfo item in playInfoList) { dic.Add(item.Definition,item.PlayURL); } } return dic; } catch (Exception ex) { return null; throw; } } public Dictionary<string, string> GetHRVideoDefinition(string strVid) { try { GetPlayInfoRequest request = new GetPlayInfoRequest(); Dictionary<string, string> dic = new Dictionary<string, string>(); request.VideoId = strVid; DefaultAcsClient client = InitVodClient(); GetPlayInfoResponse response = client.GetAcsResponse(request); List<GetPlayInfoResponse.GetPlayInfo_PlayInfo> playInfoList = response.PlayInfoList; if (playInfoList.Count > 0) { foreach (GetPlayInfoResponse.GetPlayInfo_PlayInfo item in playInfoList) { dic.Add(item.Definition, item.PlayURL); } } return dic; } catch (Exception ex) { return null; throw; } } public string GetVideoPlayAuth(string strVid) { try { GetVideoPlayAuthRequest request = new GetVideoPlayAuthRequest(); string strAliVid = this.GetAliVid(strVid); if (string.IsNullOrEmpty(strAliVid)) { return string.Empty; } request.VideoId = strAliVid; DefaultAcsClient client = InitVodClient(); GetVideoPlayAuthResponse response = client.GetAcsResponse(request); string strPlayAuth = response.PlayAuth; if (string.IsNullOrEmpty(strPlayAuth)) { return string.Empty; } return strPlayAuth; } catch (Exception ex) { return string.Empty; throw; } } public string GetHRVideoPlayAuth(string strVid) { try { GetVideoPlayAuthRequest request = new GetVideoPlayAuthRequest(); request.VideoId = strVid; DefaultAcsClient client = InitVodClient(); GetVideoPlayAuthResponse response = client.GetAcsResponse(request); string strPlayAuth = response.PlayAuth; if (string.IsNullOrEmpty(strPlayAuth)) { return string.Empty; } return strPlayAuth; } catch (Exception ex) { return string.Empty; throw; } } public bool RefreshUploadVideo(string strVid) { RefreshUploadVideoRequest request = new RefreshUploadVideoRequest(); request.VideoId = strVid; DefaultAcsClient client = InitVodClient(); RefreshUploadVideoResponse response = client.GetAcsResponse(request); return true; }

      

  • 相关阅读:
    如何远程关闭一个ASP.NET Core应用?
    Asp.Net Core 2.x 和 3.x WebAPI 使用 Swagger 时 API Controller 控制器 Action 方法 隐藏 hidden 与 and 分组 group
    Swashbuckle.AspNetCore3.0的二次封装与使用
    微服务日志之.NET Core使用NLog通过Kafka实现日志收集
    细说ASP.NET Core静态文件的缓存方式
    ASP.NET Core中的ActionFilter与DI
    查看.NET Core源代码通过Autofac实现依赖注入到Controller属性
    使用 python set 去重 速度到底是多快呢???
    搜狐视频 登录 md5 加密破解
    python 实现 DES CBC模式加解密
  • 原文地址:https://www.cnblogs.com/xuxian001/p/13072076.html
Copyright © 2011-2022 走看看