正在显示
6 个修改的文件
包含
106 行增加
和
3 行删除
| @@ -54,3 +54,45 @@ func (this *VodController) CreateUploadImage() { | @@ -54,3 +54,45 @@ func (this *VodController) CreateUploadImage() { | ||
| 54 | header := controllers.GetRequestHeader(this.Ctx) | 54 | header := controllers.GetRequestHeader(this.Ctx) |
| 55 | msg = protocol.NewReturnResponse(upload.CreateUploadImage(header, request)) | 55 | msg = protocol.NewReturnResponse(upload.CreateUploadImage(header, request)) |
| 56 | } | 56 | } |
| 57 | + | ||
| 58 | +//获取视频播放地址 GetPlayInfo | ||
| 59 | +// @router /getPlayInfo [post] | ||
| 60 | +func (this *VodController) GetPlayInfo() { | ||
| 61 | + var msg *protocol.ResponseMessage | ||
| 62 | + defer func() { | ||
| 63 | + this.Resp(msg) | ||
| 64 | + }() | ||
| 65 | + var request *aliyun.GetPlayInfoRequest | ||
| 66 | + if err := json.Unmarshal(this.ByteBody, &request); err != nil { | ||
| 67 | + log.Error(err) | ||
| 68 | + msg = protocol.BadRequestParam(1) | ||
| 69 | + return | ||
| 70 | + } | ||
| 71 | + if b, m := this.Valid(request); !b { | ||
| 72 | + msg = m | ||
| 73 | + return | ||
| 74 | + } | ||
| 75 | + header := controllers.GetRequestHeader(this.Ctx) | ||
| 76 | + msg = protocol.NewReturnResponse(upload.GetPlayInfo(header, request)) | ||
| 77 | +} | ||
| 78 | + | ||
| 79 | +//获取视频播放凭证 GetVideoPlayAuth | ||
| 80 | +// @router /getVideoPlayAuth [post] | ||
| 81 | +func (this *VodController) GetVideoPlayAuth() { | ||
| 82 | + var msg *protocol.ResponseMessage | ||
| 83 | + defer func() { | ||
| 84 | + this.Resp(msg) | ||
| 85 | + }() | ||
| 86 | + var request *aliyun.GetVideoPlayAuthRequest | ||
| 87 | + if err := json.Unmarshal(this.ByteBody, &request); err != nil { | ||
| 88 | + log.Error(err) | ||
| 89 | + msg = protocol.BadRequestParam(1) | ||
| 90 | + return | ||
| 91 | + } | ||
| 92 | + if b, m := this.Valid(request); !b { | ||
| 93 | + msg = m | ||
| 94 | + return | ||
| 95 | + } | ||
| 96 | + header := controllers.GetRequestHeader(this.Ctx) | ||
| 97 | + msg = protocol.NewReturnResponse(upload.GetVideoPlayAuth(header, request)) | ||
| 98 | +} |
| @@ -25,6 +25,11 @@ type GetPlayInfoResponse struct { | @@ -25,6 +25,11 @@ type GetPlayInfoResponse struct { | ||
| 25 | PlayInfoList PlayInfoListInGetPlayInfo `json:"PlayInfoList" xml:"PlayInfoList"` | 25 | PlayInfoList PlayInfoListInGetPlayInfo `json:"PlayInfoList" xml:"PlayInfoList"` |
| 26 | } | 26 | } |
| 27 | 27 | ||
| 28 | +/*获取视频播放凭证*/ | ||
| 29 | +type GetVideoPlayAuthRequest struct { | ||
| 30 | + VideoId string `json:"videoId" xml:"VideoId"` | ||
| 31 | +} | ||
| 32 | + | ||
| 28 | // VideoBase is a nested struct in vod response | 33 | // VideoBase is a nested struct in vod response |
| 29 | type VideoBase struct { | 34 | type VideoBase struct { |
| 30 | OutputType string `json:"OutputType" xml:"OutputType"` | 35 | OutputType string `json:"OutputType" xml:"OutputType"` |
| @@ -72,13 +72,21 @@ func CreateUploadImage(client *vod.Client, r *CreateUploadImageRequest) (respons | @@ -72,13 +72,21 @@ func CreateUploadImage(client *vod.Client, r *CreateUploadImageRequest) (respons | ||
| 72 | } | 72 | } |
| 73 | 73 | ||
| 74 | //获取播放信息 | 74 | //获取播放信息 |
| 75 | -func GetPlayInfo(client *vod.Client, videoId string) (response *vod.GetPlayInfoResponse, err error) { | 75 | +func GetPlayInfo(client *vod.Client, r *GetPlayInfoRequest) (response *vod.GetPlayInfoResponse, err error) { |
| 76 | request := vod.CreateGetPlayInfoRequest() | 76 | request := vod.CreateGetPlayInfoRequest() |
| 77 | - request.VideoId = videoId | 77 | + request.VideoId = r.VideoId |
| 78 | request.AcceptFormat = "JSON" | 78 | request.AcceptFormat = "JSON" |
| 79 | return client.GetPlayInfo(request) | 79 | return client.GetPlayInfo(request) |
| 80 | } | 80 | } |
| 81 | 81 | ||
| 82 | +//获取播放信息 | ||
| 83 | +func GetGetVideoPlayAuth(client *vod.Client, r *GetVideoPlayAuthRequest) (response interface{}, err error) { | ||
| 84 | + request := vod.CreateGetVideoPlayAuthRequest() | ||
| 85 | + request.VideoId = r.VideoId | ||
| 86 | + request.AcceptFormat = "JSON" | ||
| 87 | + return client.GetVideoPlayAuth(request) | ||
| 88 | +} | ||
| 89 | + | ||
| 82 | //fileType: video voice image | 90 | //fileType: video voice image |
| 83 | func getFileName(fileType string, filename string) string { | 91 | func getFileName(fileType string, filename string) string { |
| 84 | date := comm_time.GetTimeByYyyymmdd() | 92 | date := comm_time.GetTimeByYyyymmdd() |
| @@ -631,4 +631,20 @@ func init() { | @@ -631,4 +631,20 @@ func init() { | ||
| 631 | MethodParams: param.Make(), | 631 | MethodParams: param.Make(), |
| 632 | Params: nil}) | 632 | Params: nil}) |
| 633 | 633 | ||
| 634 | + beego.GlobalControllerRouter["opp/controllers/v1:VodController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:VodController"], | ||
| 635 | + beego.ControllerComments{ | ||
| 636 | + Method: "GetPlayInfo", | ||
| 637 | + Router: `/getPlayInfo`, | ||
| 638 | + AllowHTTPMethods: []string{"post"}, | ||
| 639 | + MethodParams: param.Make(), | ||
| 640 | + Params: nil}) | ||
| 641 | + | ||
| 642 | + beego.GlobalControllerRouter["opp/controllers/v1:VodController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:VodController"], | ||
| 643 | + beego.ControllerComments{ | ||
| 644 | + Method: "GetVideoPlayAuth", | ||
| 645 | + Router: `/getVideoPlayAuth`, | ||
| 646 | + AllowHTTPMethods: []string{"post"}, | ||
| 647 | + MethodParams: param.Make(), | ||
| 648 | + Params: nil}) | ||
| 649 | + | ||
| 634 | } | 650 | } |
| @@ -16,7 +16,7 @@ func GetPlayInfo(header *protocol.RequestHeader, request *aliyun.GetPlayInfoRequ | @@ -16,7 +16,7 @@ func GetPlayInfo(header *protocol.RequestHeader, request *aliyun.GetPlayInfoRequ | ||
| 16 | err = e | 16 | err = e |
| 17 | return | 17 | return |
| 18 | } | 18 | } |
| 19 | - response, e := aliyun.GetPlayInfo(client, request.VideoId) | 19 | + response, e := aliyun.GetPlayInfo(client, request) |
| 20 | if e != nil { | 20 | if e != nil { |
| 21 | log.Error(e) | 21 | log.Error(e) |
| 22 | err = e | 22 | err = e |
| @@ -163,3 +163,35 @@ func CreateUploadImage(header *protocol.RequestHeader, request *aliyun.CreateUpl | @@ -163,3 +163,35 @@ func CreateUploadImage(header *protocol.RequestHeader, request *aliyun.CreateUpl | ||
| 163 | } | 163 | } |
| 164 | return | 164 | return |
| 165 | } | 165 | } |
| 166 | + | ||
| 167 | +//获取视频播放地址 | ||
| 168 | +func GetPlayInfo(header *protocol.RequestHeader, request *aliyun.GetPlayInfoRequest) (rsp interface{}, err error) { | ||
| 169 | + var () | ||
| 170 | + client, e := aliyun.DefaultVodClient() | ||
| 171 | + if e != nil { | ||
| 172 | + log.Error(e) | ||
| 173 | + err = e | ||
| 174 | + return | ||
| 175 | + } | ||
| 176 | + rsp, err = aliyun.GetPlayInfo(client, request) | ||
| 177 | + if err != nil { | ||
| 178 | + log.Error(err) | ||
| 179 | + } | ||
| 180 | + return | ||
| 181 | +} | ||
| 182 | + | ||
| 183 | +//获取视频播放凭证 | ||
| 184 | +func GetVideoPlayAuth(header *protocol.RequestHeader, request *aliyun.GetVideoPlayAuthRequest) (rsp interface{}, err error) { | ||
| 185 | + var () | ||
| 186 | + client, e := aliyun.DefaultVodClient() | ||
| 187 | + if e != nil { | ||
| 188 | + log.Error(e) | ||
| 189 | + err = e | ||
| 190 | + return | ||
| 191 | + } | ||
| 192 | + rsp, err = aliyun.GetGetVideoPlayAuth(client, request) | ||
| 193 | + if err != nil { | ||
| 194 | + log.Error(err) | ||
| 195 | + } | ||
| 196 | + return | ||
| 197 | +} |
-
请 注册 或 登录 后发表评论