File tree Expand file tree Collapse file tree 1 file changed +6
-6
lines changed
Expand file tree Collapse file tree 1 file changed +6
-6
lines changed Original file line number Diff line number Diff line change @@ -44,17 +44,17 @@ export function parseMys(data: string): Document {
4444 const div = document . createElement ( "div" ) ;
4545 // 创建视频
4646 const video = document . createElement ( "video" ) ;
47+ // 获取 resolutions,将其作为 source
48+ const resolution = item . insert . vod . resolutions . pop ( ) ;
4749 // 设置一些属性
4850 video . poster = item . insert . vod . cover ; // 设置封面
49- video . height = item . insert . vod . resolutions [ 0 ] . height ; // 设置高度
50- video . width = item . insert . vod . resolutions [ 0 ] . width ; // 设置宽度
51+ video . width = resolution . width > 800 ? 800 : resolution . width ; // 设置宽度(取最高分辨率的宽度)
52+ video . height = resolution . width > 800 ? 450 : resolution . height ; // 设置高度(取最高分辨率的高度)
5153 video . controls = true ; // 设置 controls
52- // 获取 resolutions,将其作为 source
53- const resolutions = item . insert . vod . resolutions ;
5454 // 添加 source
5555 const source = document . createElement ( "source" ) ;
56- source . src = resolutions [ 0 ] . url ;
57- source . type = resolutions [ 0 ] . format === ".mp4" ? "video/mp4" : "video/webm" ;
56+ source . src = resolution . url ;
57+ source . type = resolution . format === ".mp4" ? "video/mp4" : "video/webm" ;
5858 video . appendChild ( source ) ;
5959 // 添加 controls
6060 video . controls = true ;
You can’t perform that action at this time.
0 commit comments