From 36969a664857d4ecce6f413412ee517db8f26506 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=A7=89?= Date: Wed, 25 Oct 2023 05:38:45 +0800 Subject: [PATCH] =?UTF-8?q?=E8=BD=AC=E7=A0=81=E7=AD=89=E5=BE=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- models/video.go | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/models/video.go b/models/video.go index a8c3e45..37b0215 100644 --- a/models/video.go +++ b/models/video.go @@ -7,6 +7,7 @@ import ( "fmt" "log" "regexp" + "time" openapi "github.com/alibabacloud-go/darabonba-openapi/client" "github.com/alibabacloud-go/tea/tea" @@ -41,7 +42,7 @@ func GetVideoM3U8(content string) (playinfo *vod20170321.GetPlayInfoResponseBody if _err != nil { return nil, _err } - // TODO: 返回播放地址列表 + // 返回播放地址列表 return result.Body.PlayInfoList, nil } @@ -79,6 +80,25 @@ func GetVideoM3U8(content string) (playinfo *vod20170321.GetPlayInfoResponseBody fmt.Println("上传视频结束") + count := 0 + // 查询等待完成转码, 最多等待2分钟 + for { + getMezzanineInfo, _err := client.GetMezzanineInfo(&vod20170321.GetMezzanineInfoRequest{ + VideoId: createUploadVideoResponse.Body.VideoId, + }) + if _err != nil { + return nil, _err + } + if *getMezzanineInfo.Body.Mezzanine.Status == "Normal" || *getMezzanineInfo.Body.Mezzanine.Status == "Fail" { + break + } + time.Sleep(time.Second * 1) + count++ + if count > 120 { + return nil, errors.New("转码超时") + } + } + // fmt.Println("UploadAuth", *createUploadVideoResponse.Body.UploadAuth) // 4.媒体上传完成之后,可以获取媒体播放信息进行播放 // 4.1 通过播放凭证播放