{"id":19640095,"url":"https://github.com/chimeejs/chimee-plugin-danmu","last_synced_at":"2025-04-28T11:31:02.207Z","repository":{"id":57197973,"uuid":"98143193","full_name":"Chimeejs/chimee-plugin-danmu","owner":"Chimeejs","description":"chimee danmu video ","archived":false,"fork":false,"pushed_at":"2019-03-11T09:10:41.000Z","size":341,"stargazers_count":9,"open_issues_count":2,"forks_count":6,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-04-14T13:57:24.637Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Chimeejs.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-07-24T02:55:36.000Z","updated_at":"2020-07-08T11:19:55.000Z","dependencies_parsed_at":"2022-09-16T13:12:27.313Z","dependency_job_id":null,"html_url":"https://github.com/Chimeejs/chimee-plugin-danmu","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Chimeejs%2Fchimee-plugin-danmu","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Chimeejs%2Fchimee-plugin-danmu/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Chimeejs%2Fchimee-plugin-danmu/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Chimeejs%2Fchimee-plugin-danmu/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Chimeejs","download_url":"https://codeload.github.com/Chimeejs/chimee-plugin-danmu/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251304764,"owners_count":21567933,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-11T14:04:37.717Z","updated_at":"2025-04-28T11:30:59.682Z","avatar_url":"https://github.com/Chimeejs.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 弹幕组件\n\n\u003e 使用 css ／ canvas 实现弹幕\n\n## 安装使用\n\n1. 安装\n\n```shell\nnpm install chimee-plugin-danmu\n```\n\n2. 使用\n\n```javascript\nimport chimee from 'chimee';\nimport chimeePluginDanmu from 'chimee-plugin-danmu';\n\n// 安装插件\nchimee.install(chimeeDanmu);\nconst player = new chimee({\n  // ...\n  // 使用插件\n  plugin: [\n    chimeePluginDanmu.name\n  ]\n});\n```\n\n**也可以在页面中引用 /lib/index.browser.js 然后在页面中使用 chimeePluginDanmu**\n\n## 配置\n\n### mode\n\n  * 类型： String\n  * 含义： 弹幕使用 canvas 还是 css 渲染\n  * 默认： 'css'\n  * 值： 'css' , 'canvas'\n\n### lineHeight\n\n  * 类型： Number\n  * 含义： 弹幕道的高度\n  * 默认： 30\n\n### fontSize\n\n  * 类型： Number | String\n  * 含义： 字体大小 |（大号 big）/（小号／ small) \n  * 默认值： big\n\n### updateByVideo\n\n  * 类型： Boolean\n  * 含义： 弹幕是否与视频状态同步，视频播放／暂停状态对应弹幕的播放暂停\n  * 默认： true, 默认是同步的\n  * 值： true / false\n\n\n## 方法\n\n### start\n\n  * 作用： 弹幕开始\n  * 类型： Function\n  * 参数： 空\n  * 返回： 空\n\n### pause\n\n  * 作用： 弹幕暂停\n  * 类型： Function\n  * 参数： 空\n  * 返回： 空\n\n### open\n\n  * 作用： 打开弹幕\n  * 类型： Function\n  * 参数： 空\n  * 返回： 空\n\n### close\n\n  * 作用： 关闭弹幕\n  * 类型： Function\n  * 参数： 空\n  * 返回： 空\n\n### changeMode\n\n  * 作用： 切换弹幕渲染方式\n  * 类型： Function\n  * 参数： mode\n    * 类型： String\n    * 含义： 替换的模式， 可传 'css' 或者 'canvas' 不可以为空\n  * 返回： 空\n\n### sendMsg\n\n  * 作用： 发送弹幕\n  * 类型： Function\n  * 参数： data\n    * 类型： Object\n      * text\n        * 类型： String\n        * 含义： 弹幕内容\n      * mode\n        * 类型： String\n        * 含义： 弹幕展现方式（固定下方 top/ 固定上方bottom）／滚动弹幕(flow)\n        * 默认值： flow\n      * fontSize\n        * 类型： Number | String\n        * 含义： 字体大小 |（大号 big）/（小号／ small) \n        * 默认值： big\n      * color\n        * 类型： String\n        * 含义： 弹幕颜色\n        * 默认值： #fff\n      * speed\n        * 类型： Number\n        * 含义： 弹幕每 16ms 的一个步长\n        * 默认值： 根据弹幕宽度计算 `Math.pow(piece.width, 1 / 3) * 0.3`\n      \n    * 含义： 替换的模式， 可传 'css' 或者 'canvas' 不可以为空\n  * 返回： 空\n\n```javascript\n  const defaultData = {\n    text: '你真的很漂亮',\n    mode: 'flow',\n    fontSize: 'big',\n    color: '#fff'\n  };\n\n```\n\n### receiveData\n\n  * 作用： 接受弹幕的初始数据\n  * 类型： Function\n  * 参数： data\n    * 类型： Array\n    * 含义： 初始化塞入的所有数据\n  * 返回： 空\n\n\n## 事件\n\n### danmuContextmenu\n\n  * 作用：监听弹幕右键点击事件\n  * 回调函数参数： \n    * pieces: \n      * 类型: Array\n      * 含义: 位于这个位置的所有弹幕集合\n\n\n## 其他\n\n### Q: 如何实现弹幕右键弹窗\n\n  用户可以监听 danmuContextmenu 事件，拿到该点下面的所有弹幕，然后使用 chimee-plugin-pop 插件，来自己构造弹窗（原因：弹窗内容根据业务场景会有不同的定制情况）\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchimeejs%2Fchimee-plugin-danmu","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fchimeejs%2Fchimee-plugin-danmu","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchimeejs%2Fchimee-plugin-danmu/lists"}