(自用)哔哩哔哩外链播放器代码 - 存档

引用地址

https://player.bilibili.com/player.html

使用示例

    <iframe style="width:640px; height:360px;" 
    src="https://player.bilibili.com/player.html?bvid=BV1Ex4y1z7FU&autoplay=0&danmaku=1&muted=1" 
    scrolling="no" frameborder="no" framespacing="0" allowfullscreen="true" >
    </iframe>
            

style中预留了640×360的空间来显示完整的播放控件,
URL的src中:
autoplay=0指定了不自动播放,
danmaku=1设置了显示弹幕,
muted=1设置了静音播放,

如果网站完全由自己控制,最好参考网页头中iframe-example的写法进行分辨率适配

    @supports (aspect-ratio: 16 / 9) {
        .iframe-example {
            max-width: 720px;
            width: 100%;
            height: auto;
            aspect-ratio: 16 / 9;
        }
    }
    .iframe-example iframe {
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
    }
        

QueryString 参数

boolean 类型,在 QueryString 中可以使用 0 和 1 表示。

参数名 类型 必要 说明
aid number UGC 视频 ID。aid、bvid 选择其一即可
cid number UGC 视频 ID
bvid string ✅ UGC 视频 ID。aid、bvid 选择其一即可
seasonId number OGV 视频 ID
episodeId number ✅ OGV 视频 ID。优先级高于 aid、bvid
poster boolean 展示封面
autoplay boolean 自动播放
muted boolean 静音
t number 跳转到媒体的初始时间点,单位:秒
danmaku boolean false 表示关闭弹幕,其他表示默认值
kind number 群组种类。非通用业务需要此参数
refer boolean 跳链时携带当前的 Referrer。用于合作方查询来自嵌入网站的跳转次数
p number 多 P 视频的集数。从 1 开始计数,若有 cid 参数,则此参数不生效