{"id":13672921,"url":"https://github.com/huruji/moedan","last_synced_at":"2025-08-02T15:04:57.501Z","repository":{"id":57300850,"uuid":"178365403","full_name":"huruji/moedan","owner":"huruji","description":"Moedan — 简单、小巧、实用的弹幕引擎","archived":false,"fork":false,"pushed_at":"2019-04-15T13:59:18.000Z","size":7359,"stargazers_count":15,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-07-04T23:41:39.698Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"TypeScript","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/huruji.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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":"2019-03-29T08:34:32.000Z","updated_at":"2024-10-04T04:13:47.000Z","dependencies_parsed_at":"2022-09-19T04:31:25.560Z","dependency_job_id":null,"html_url":"https://github.com/huruji/moedan","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/huruji/moedan","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/huruji%2Fmoedan","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/huruji%2Fmoedan/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/huruji%2Fmoedan/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/huruji%2Fmoedan/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/huruji","download_url":"https://codeload.github.com/huruji/moedan/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/huruji%2Fmoedan/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":268408189,"owners_count":24245576,"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","status":"online","status_checked_at":"2025-08-02T02:00:12.353Z","response_time":74,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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-08-02T09:01:57.407Z","updated_at":"2025-08-02T15:04:57.446Z","avatar_url":"https://github.com/huruji.png","language":"TypeScript","readme":"\u003cp align=\"center\"\u003e\n\u003cimg width=\"70%\" src=\"./logo.png\" alt=\"moedan\"\u003e\n\u003c/p\u003e\n\n# moedan\n简单、小巧、实用的弹幕引擎\n\n![](./use.gif)\n## How to use\n```bash\nnpm i moedan -S\n```\n\n```js\nimport Moedan from 'moedan'\nimport './moedan/dist/Moedan.css'\n\nconst danmakuDada = [\n  {\n    content: '666',\n    time: 1.22\n  },\n  {\n    content: 'did a good job',\n    time: 8.90\n  }\n]\nconst player = document.querySelector('video.myvoideo')\nconst Danmaku = new Moedan({\n  data: danmakuData,\n  container: document.querySelector('.danmaku_container'),\n  player\n})\n\nplayer.addEventListener('play', () =\u003e {\n  Danmaku.play()\n})\n\n```\n\n## 参数\n\n实例化 `Moedan` 的参数\n\n### container\n\ntype: `HTMLElement`\n\n存放弹幕元素的容器元素\n\n### data\n\ntype: `Array`\n\n弹幕数据，数据格式需包含 `time` 和 `content` 属性，分别代表弹幕在视频的时间和内容\n\n```js\n[\n  {\n    content: '666',\n    time: 1.22\n  },\n  {\n    content: 'did a good job',\n    time: 8.90\n  }\n]\n```\n\n### player\n\ntype: `HTMLElement`\n\n对应的视频元素\n\n### tunnels\n\ntype: `Number`\n\ndefault: 3\n\n出现弹幕的轨道数量\n\n### time\n\ntype: `Number`\n\ndefault: 6\n\n一条弹幕从出现到消失的时间，单位：秒\n\n## API\n\n### Danmaku.clear()\n\n清除弹幕\n\n```js\nDanmaku.clear()\n```\n\n\n### Danmaku.hide()\n\n隐藏弹幕，一般和隐藏弹幕按钮一块使用\n\n### Danmaku.pause()\n\n暂停弹幕，应该和视频一起播放\n\n```js\nPlayer.addEventListener('pause', () =\u003e Danmaku.play())\n```\n\n### Danmaku.play()\n\n播放弹幕，应该和视频一起播放\n\n```js\nPlayer.addEventListener('play', () =\u003e Danmaku.play())\n```\n\n### Danmaku.reload()\n\n重新 load 弹幕，应该和视频重播一起使用\n\n```js\nPlayer.addEventListener('ended', () =\u003e Danmaku.reload())\n```\n\n### Danmaku.seek()\n\n重新定位弹幕，一般和拖动播放器进度条一起使用\n\n```js\n// when update video's currentTime\nDanmaku.seek()\n```\n\n### Danmaku.show()\n\n显示弹幕，一般和显示弹幕按钮一块使用\n\n\n","funding_links":[],"categories":["TypeScript"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhuruji%2Fmoedan","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhuruji%2Fmoedan","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhuruji%2Fmoedan/lists"}