Skip to content

添加弹幕 ​

注意

该方法回调为异步事件,请参考方法事件

方法名 ​

addDanmaku

用法 ​

js
this.$refs.refVideoPlayer.addDanmaku({
  //文本
  text: "这是一条刚刚发送的测试弹幕",
  //内边距
  padding: 5,
  //弹幕优先级,0为低优先级,>0为高优先级不会被过滤器过滤
  priority: 8,
  //是否是直播弹幕
  isLive: true,
  //弹幕出现时间,弹幕当前时间延迟时间,单位:毫秒
  time: 500,
  //字体大小
  textSize: 45,
  //文本颜色
  textColor: "#FF0000",
  //阴影/描边颜色
  textShadowColor: "#FFFFFF",
  //边框的颜色
  borderColor: "#00FF00"
})
js
let options = {
  //文本
  text: "这是一条刚刚发送的测试弹幕",
  //内边距
  padding: 5,
  //弹幕优先级,0为低优先级,>0为高优先级不会被过滤器过滤
  priority: 8,
  //是否是直播弹幕
  isLive: true,
  //弹幕出现时间,弹幕当前时间延迟时间,单位:毫秒
  time: 500,
  //字体大小
  textSize: 45,
  //文本颜色
  textColor: "#FF0000",
  //阴影/描边颜色
  textShadowColor: "#FFFFFF",
  //边框的颜色
  borderColor: "#00FF00"
};
let params : JSONObject = JSONObject.parse(JSON.stringify(options)) as JSONObject
refLevenPlayer.value?.addDanmaku(params);

参数说明 ​

参数名参数类型是否必填默认值参数描述
textString是无弹幕内容
paddingInteger否0内边距
priorityInteger否0弹幕优先级,0为低优先级,>0为高优先级不会被过滤器过滤
isLiveBoolean否false是否是直播弹幕
timeInteger是无弹幕出现时间,弹幕当前时间延迟时间,单位:毫秒
textSizeInteger否无内边距
textColorString否无文本颜色
textShadowColorString否无阴影/描边颜色
borderColorString否无边框的颜色