作者 yangfu

阿里云视频点播修改

... ... @@ -54,3 +54,45 @@ func (this *VodController) CreateUploadImage() {
header := controllers.GetRequestHeader(this.Ctx)
msg = protocol.NewReturnResponse(upload.CreateUploadImage(header, request))
}
//获取视频播放地址 GetPlayInfo
// @router /getPlayInfo [post]
func (this *VodController) GetPlayInfo() {
var msg *protocol.ResponseMessage
defer func() {
this.Resp(msg)
}()
var request *aliyun.GetPlayInfoRequest
if err := json.Unmarshal(this.ByteBody, &request); err != nil {
log.Error(err)
msg = protocol.BadRequestParam(1)
return
}
if b, m := this.Valid(request); !b {
msg = m
return
}
header := controllers.GetRequestHeader(this.Ctx)
msg = protocol.NewReturnResponse(upload.GetPlayInfo(header, request))
}
//获取视频播放凭证 GetVideoPlayAuth
// @router /getVideoPlayAuth [post]
func (this *VodController) GetVideoPlayAuth() {
var msg *protocol.ResponseMessage
defer func() {
this.Resp(msg)
}()
var request *aliyun.GetVideoPlayAuthRequest
if err := json.Unmarshal(this.ByteBody, &request); err != nil {
log.Error(err)
msg = protocol.BadRequestParam(1)
return
}
if b, m := this.Valid(request); !b {
msg = m
return
}
header := controllers.GetRequestHeader(this.Ctx)
msg = protocol.NewReturnResponse(upload.GetVideoPlayAuth(header, request))
}
... ...
... ... @@ -25,6 +25,11 @@ type GetPlayInfoResponse struct {
PlayInfoList PlayInfoListInGetPlayInfo `json:"PlayInfoList" xml:"PlayInfoList"`
}
/*获取视频播放凭证*/
type GetVideoPlayAuthRequest struct {
VideoId string `json:"videoId" xml:"VideoId"`
}
// VideoBase is a nested struct in vod response
type VideoBase struct {
OutputType string `json:"OutputType" xml:"OutputType"`
... ...
... ... @@ -72,13 +72,21 @@ func CreateUploadImage(client *vod.Client, r *CreateUploadImageRequest) (respons
}
//获取播放信息
func GetPlayInfo(client *vod.Client, videoId string) (response *vod.GetPlayInfoResponse, err error) {
func GetPlayInfo(client *vod.Client, r *GetPlayInfoRequest) (response *vod.GetPlayInfoResponse, err error) {
request := vod.CreateGetPlayInfoRequest()
request.VideoId = videoId
request.VideoId = r.VideoId
request.AcceptFormat = "JSON"
return client.GetPlayInfo(request)
}
//获取播放信息
func GetGetVideoPlayAuth(client *vod.Client, r *GetVideoPlayAuthRequest) (response interface{}, err error) {
request := vod.CreateGetVideoPlayAuthRequest()
request.VideoId = r.VideoId
request.AcceptFormat = "JSON"
return client.GetVideoPlayAuth(request)
}
//fileType: video voice image
func getFileName(fileType string, filename string) string {
date := comm_time.GetTimeByYyyymmdd()
... ...
... ... @@ -631,4 +631,20 @@ func init() {
MethodParams: param.Make(),
Params: nil})
beego.GlobalControllerRouter["opp/controllers/v1:VodController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:VodController"],
beego.ControllerComments{
Method: "GetPlayInfo",
Router: `/getPlayInfo`,
AllowHTTPMethods: []string{"post"},
MethodParams: param.Make(),
Params: nil})
beego.GlobalControllerRouter["opp/controllers/v1:VodController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:VodController"],
beego.ControllerComments{
Method: "GetVideoPlayAuth",
Router: `/getVideoPlayAuth`,
AllowHTTPMethods: []string{"post"},
MethodParams: param.Make(),
Params: nil})
}
... ...
... ... @@ -16,7 +16,7 @@ func GetPlayInfo(header *protocol.RequestHeader, request *aliyun.GetPlayInfoRequ
err = e
return
}
response, e := aliyun.GetPlayInfo(client, request.VideoId)
response, e := aliyun.GetPlayInfo(client, request)
if e != nil {
log.Error(e)
err = e
... ...
... ... @@ -163,3 +163,35 @@ func CreateUploadImage(header *protocol.RequestHeader, request *aliyun.CreateUpl
}
return
}
//获取视频播放地址
func GetPlayInfo(header *protocol.RequestHeader, request *aliyun.GetPlayInfoRequest) (rsp interface{}, err error) {
var ()
client, e := aliyun.DefaultVodClient()
if e != nil {
log.Error(e)
err = e
return
}
rsp, err = aliyun.GetPlayInfo(client, request)
if err != nil {
log.Error(err)
}
return
}
//获取视频播放凭证
func GetVideoPlayAuth(header *protocol.RequestHeader, request *aliyun.GetVideoPlayAuthRequest) (rsp interface{}, err error) {
var ()
client, e := aliyun.DefaultVodClient()
if e != nil {
log.Error(e)
err = e
return
}
rsp, err = aliyun.GetGetVideoPlayAuth(client, request)
if err != nil {
log.Error(err)
}
return
}
... ...