[feat] video width & autoplay

This commit is contained in:
xaoxuu 2024-01-14 11:15:37 +08:00
parent fd30e01366
commit a8c21b28a4
1 changed files with 8 additions and 8 deletions

View File

@ -9,22 +9,22 @@
'use strict';
module.exports = ctx => function(args) {
args = ctx.args.map(args, ['type', 'bilibili', 'ratio'], ['src'])
args = ctx.args.map(args, ['type', 'bilibili', 'ratio', 'width', 'autoplay'], ['src'])
if (args.width == null) {
args.width = '100%'
}
if (args.bilibili) {
return `
<div class="tag-plugin video" style="aspect-ratio:${args.ratio || 16/9}">
<iframe src="https://player.bilibili.com/player.html?bvid=${args.bilibili}" scrolling="no" border="0" frameborder="no" framespacing="0" allowfullscreen="true">
<div class="tag-plugin video" style="aspect-ratio:${args.ratio || 16/9};max-width:${args.width};">
<iframe src="https://player.bilibili.com/player.html?bvid=${args.bilibili}&autoplay=${args.autoplay || 'false'}" scrolling="no" border="0" frameborder="no" framespacing="0" allowfullscreen="true">
</iframe>
</div>
`
}
if (args.type == null) {
args.type = 'video/mp4'
}
return `
<div class="tag-plugin video">
<div class="tag-plugin video" style="max-width:${args.width};">
<video controls preload>
<source src="${args.src}" type="${args.type}">Your browser does not support the video tag.
<source src="${args.src}" type="${args.type || 'video/mp4'}">Your browser does not support the video tag.
</video>
</div>
`