text: "use strict";(self.webpackChunkartplayer_document=self.webpackChunkartplayer_document||[]).push([[78],{876:function(n,e,t){t.d(e,{Zo:function(){return s},kt:function(){return c}});var a=t(2784);function r(n,e,t){return e in n?Object.defineProperty(n,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):n[e]=t,n}function l(n,e){var t=Object.keys(n);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(n);e&&(a=a.filter((function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),t.push.apply(t,a)}return t}function u(n){for(var e=1;e<arguments.length;e++){var t=null!=arguments[e]?arguments[e]:{};e%2?l(Object(t),!0).forEach((function(e){r(n,e,t[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(t)):l(Object(t)).forEach((function(e){Object.defineProperty(n,e,Object.getOwnPropertyDescriptor(t,e))}))}return n}function i(n,e){if(null==n)return{};var t,a,r=function(n,e){if(null==n)return{};var t,a,r={},l=Object.keys(n);for(a=0;a<l.length;a++)t=l[a],e.indexOf(t)>=0||(r[t]=n[t]);return r}(n,e);if(Object.getOwnPropertySymbols){var l=Object.getOwnPropertySymbols(n);for(a=0;a<l.length;a++)t=l[a],e.indexOf(t)>=0||Object.prototype.propertyIsEnumerable.call(n,t)&&(r[t]=n[t])}return r}var o=a.createContext({}),p=function(n){var e=a.useContext(o),t=e;return n&&(t="function"==typeof n?n(e):u(u({},e),n)),t},s=function(n){var e=p(n.components);return a.createElement(o.Provider,{value:e},n.children)},m={inlineCode:"code",wrapper:function(n){var e=n.children;return a.createElement(a.Fragment,{},e)}},d=a.forwardRef((function(n,e){var t=n.components,r=n.mdxType,l=n.originalType,o=n.parentName,s=i(n,["components","mdxType","originalType","parentName"]),d=p(t),c=r,k=d["".concat(o,".").concat(c)]||d[c]||m[c]||l;return t?a.createElement(k,u(u({ref:e},s),{},{components:t})):a.createElement(k,u({ref:e},s))}));function c(n,e){var t=arguments,r=e&&e.mdxType;if("string"==typeof n||r){var l=t.length,u=new Array(l);u[0]=d;var i={};for(var o in e)hasOwnProperty.call(e,o)&&(i[o]=e[o]);i.originalType=n,i.mdxType="string"==typeof n?n:r,u[1]=i;for(var p=2;p<l;p++)u[p]=t[p];return a.createElement.apply(null,u)}return a.createElement.apply(null,t)}d.displayName="MDXCreateElement"},9942:function(n,e,t){t.r(e),t.d(e,{assets:function(){return s},contentTitle:function(){return o},default:function(){return c},frontMatter:function(){return i},metadata:function(){return p},toc:function(){return m}});var a=t(7896),r=t(1461),l=(t(2784),t(876)),u=["components"],i={title:"\u5f39\u5e55\u5e93\u63d2\u4ef6",sidebar_position:1},o=void 0,p={unversionedId:"zh-cn/Plugins/danmuku",id:"zh-cn/Plugins/danmuku",title:"\u5f39\u5e55\u5e93\u63d2\u4ef6",description:"\u6f14\u793a",source:"@site/docs/zh-cn/Plugins/danmuku.mdx",sourceDirName:"zh-cn/Plugins",slug:"/zh-cn/Plugins/danmuku",permalink:"/document/zh-cn/Plugins/danmuku",draft:!1,tags:[],version:"current",sidebarPosition:1,frontMatter:{title:"\u5f39\u5e55\u5e93\u63d2\u4ef6",sidebar_position:1},sidebar:"zh-cn",previous:{title:"\u7b2c\u4e09\u65b9\u5e93",permalink:"/document/zh-cn/libraries"},next:{title:"\u5728\u63a7\u5236\u680f\u6dfb\u52a0\u5217\u8868",permalink:"/document/zh-cn/Questions/Create_selector_in_the_controls"}},s={},m=[{value:"\u6f14\u793a",id:"\u6f14\u793a",level:2},{value:"\u5b89\u88c5",id:"\u5b89\u88c5",level:2},{value:"\u901a\u8fc7 <code>npm</code> \u5b89\u88c5\uff1a",id:"\u901a\u8fc7-npm-\u5b89\u88c5",level:3},{value:"\u901a\u8fc7 <code>yarn</code> \u5b89\u88c5\uff1a",id:"\u901a\u8fc7-yarn-\u5b89\u88c5",level:3},{value:"\u901a\u8fc7 <code>script</code> \u5b89\u88c5\uff1a",id:"\u901a\u8fc7-script-\u5b89\u88c5",level:3},{value:"\u4f7f\u7528",id:"\u4f7f\u7528",level:2},{value:"\u4f7f\u7528\u5f39\u5e55\u6570\u7ec4",id:"\u4f7f\u7528\u5f39\u5e55\u6570\u7ec4",level:3},{value:"\u4f7f\u7528\u5f39\u5e55 XML",id:"\u4f7f\u7528\u5f39\u5e55-xml",level:3},{value:"\u4f7f\u7528\u5f02\u6b65\u8c03\u7528",id:"\u4f7f\u7528\u5f02\u6b65\u8c03\u7528",level:3},{value:"\u63a5\u53e3",id:"\u63a5\u53e3",level:2},{value:"hide/show",id:"hideshow",level:3},{value:"isHide",id:"ishide",level:3},{value:"emit",id:"emit",level:3},{value:"config",id:"config",level:3},{value:"load",id:"load",level:3},{value:"\u4e8b\u4ef6",id:"\u4e8b\u4ef6",level:2}],d={toc:m};function c(n){var e=n.components,t=(0,r.Z)(n,u);return(0,l.kt)("wrapper",(0,a.Z)({},d,t,{components:e,mdxType:"MDXLayout"}),(0,l.kt)("h2",{id:"\u6f14\u793a"},"\u6f14\u793a"),(0,l.kt)("p",null,"\ud83d\udc49 ",(0,l.kt)("a",{parentName:"p",href:"https://artplayer.org/?libs=./uncompiled/artplayer-plugin-danmuku/index.js&example=danmuku"},"\u67e5\u770b\u5b8c\u6574\u6f14\u793a")),(0,l.kt)("h2",{id:"\u5b89\u88c5"},"\u5b89\u88c5"),(0,l.kt)("h3",{id:"\u901a\u8fc7-npm-\u5b89\u88c5"},"\u901a\u8fc7 ",(0,l.kt)("inlineCode",{parentName:"h3"},"npm")," \u5b89\u88c5\uff1a"),(0,l.kt)("pre",null,(0,l.kt)("code",{parentName:"pre",className:"language-bash"},"$ npm install artplayer-plugin-danmuku\n")),(0,l.kt)("h3",{id:"\u901a\u8fc7-yarn-\u5b89\u88c5"},"\u901a\u8fc7 ",(0,l.kt)("inlineCode",{parentName:"h3"},"yarn")," \u5b89\u88c5\uff1a"),(0,l.kt)("pre",null,(0,l.kt)("code",{parentName:"pre",className:"language-bash"},"$ yarn add artplayer-plugin-danmuku\n")),(0,l.kt)("h3",{id:"\u901a\u8fc7-script-\u5b89\u88c5"},"\u901a\u8fc7 ",(0,l.kt)("inlineCode",{parentName:"h3"},"script")," \u5b89\u88c5\uff1a"),(0,l.kt)("pre",null,(0,l.kt)("code",{parentName:"pre",className:"language-html"},'\x3c!-- \u672c\u5730 --\x3e\n<script src="path/to/artplayer-plugin-danmuku/index.js"><\/script>\n\n\x3c!-- jsdelivr --\x3e\n<script src="https://cdn.jsdelivr.net/npm/artplayer-plugin-danmuku/dist/artplayer-plugin-danmuku.js"><\/script>\n\n\x3c!-- unpkg --\x3e\n<script src="https://unpkg.com/artplayer-plugin-danmuku/dist/artplayer-plugin-danmuku.js"><\/script>\n')),(0,l.kt)("p",null,"\u7136\u540e\u4f60\u53ef\u4ee5\u901a\u8fc7 ",(0,l.kt)("inlineCode",{parentName:"p"},"window.artplayerPluginDanmuku")," \u8bbf\u95ee\u5230\u63d2\u4ef6\u51fd\u6570"),(0,l.kt)("h2",{id:"\u4f7f\u7528"},"\u4f7f\u7528"),(0,l.kt)("h3",{id:"\u4f7f\u7528\u5f39\u5e55\u6570\u7ec4"},"\u4f7f\u7528\u5f39\u5e55\u6570\u7ec4"),(0,l.kt)("div",{className:"run-code","data-libs":"./uncompiled/artplayer-plugin-danmuku/index.js"},"\u25b6 Run Code"),(0,l.kt)("pre",null,(0,l.kt)("code",{parentName:"pre",className:"language-js"},"var art = new Artplayer({\n    container: '.artplayer-app',\n    url: '/assets/sample/video.mp4',\n    autoSize: true,\n    setting: true,\n    playbackRate: true,\n    fullscreenWeb: true,\n    plugins: [\n        artplayerPluginDanmuku({\n            // \u5f39\u5e55\u6570\u7ec4\n            danmuku: [\n                {\n                    text: '111', // \u5f39\u5e55\u6587\u672c\n                    time: 1, // \u53d1\u9001\u65f6\u95f4\uff0c\u5355\u4f4d\u79d2\n                    color: '#fff', // \u5f39\u5e55\u5c40\u90e8\u989c\u8272\n                    border: false, // \u662f\u5426\u663e\u793a\u63cf\u8fb9\n                    mode: 0, // \u5f39\u5e55\u6a21\u5f0f: 0\u8868\u793a\u6eda\u52a8\u30011\u9759\u6b62\n                },\n                {\n                    text: '222',\n                    time: 2,\n                    color: 'red',\n                    border: true,\n                    mode: 0,\n                },\n                {\n                    text: '333',\n                    time: 3,\n                    color: 'green',\n                    border: false,\n                    mode: 1,\n                },\n            ],\n            speed: 5, // \u5f39\u5e55\u6301\u7eed\u65f6\u95f4\uff0c\u5355\u4f4d\u79d2\uff0c\u8303\u56f4\u5728[1 ~ 10]\n            opacity: 1, // \u5f39\u5e55\u900f\u660e\u5ea6\uff0c\u8303\u56f4\u5728[0 ~ 1]\n            fontSize: 25, // \u5b57\u4f53\u5927\u5c0f\uff0c\u652f\u6301\u6570\u5b57\u548c\u767e\u5206\u6bd4\n            color: '#FFFFFF', // \u9ed8\u8ba4\u5b57\u4f53\u989c\u8272\n            mode: 0, // \u9ed8\u8ba4\u6a21\u5f0f\uff0c0-\u6eda\u52a8\uff0c1-\u9759\u6b62\n            margin: [10, '25%'], // \u5f39\u5e55\u4e0a\u4e0b\u8fb9\u8ddd\uff0c\u652f\u6301\u6570\u5b57\u548c\u767e\u5206\u6bd4\n            antiOverlap: true, // \u662f\u5426\u9632\u91cd\u53e0\n            useWorker: true, // \u662f\u5426\u4f7f\u7528 web worker\n            synchronousPlayback: false, // \u662f\u5426\u540c\u6b65\u5230\u64ad\u653e\u901f\u5ea6\n            filter: (danmu) => danmu.text.length < 50, // \u5f39\u5e55\u8fc7\u6ee4\u51fd\u6570\uff0c\u8fd4\u56de true \u5219\u53ef\u4ee5\u53d1\u9001\n            lockTime: 5, // \u8f93\u5165\u6846\u9501\u5b9a\u65f6\u95f4\uff0c\u5355\u4f4d\u79d2\uff0c\u8303\u56f4\u5728[1 ~ 60]\n            maxLength: 100, // \u8f93\u5165\u6846\u6700\u5927\u53ef\u8f93\u5165\u7684\u5b57\u6570\uff0c\u8303\u56f4\u5728[0 ~ 500]\n            minWidth: 200, // \u8f93\u5165\u6846\u6700\u5c0f\u5bbd\u5ea6\uff0c\u8303\u56f4\u5728[0 ~ 500]\uff0c\u586b 0 \u5219\u4e3a\u65e0\u9650\u5236\n            maxWidth: 400, // \u8f93\u5165\u6846\u6700\u5927\u5bbd\u5ea6\uff0c\u8303\u56f4\u5728[0 ~ Infinity]\uff0c\u586b 0 \u5219\u4e3a 100% \u5bbd\u5ea6\n            theme: 'dark', // \u8f93\u5165\u6846\u81ea\u5b9a\u4e49\u6302\u8f7d\u65f6\u7684\u4e3b\u9898\u8272\uff0c\u9ed8\u8ba4\u4e3a dark\uff0c\u53ef\u4ee5\u9009\u586b\u4eae\u8272 light\n            beforeEmit: (danmu) => !!danmu.text.trim(), // \u53d1\u9001\u5f39\u5e55\u524d\u7684\u81ea\u5b9a\u4e49\u6821\u9a8c\uff0c\u8fd4\u56de true \u5219\u53ef\u4ee5\u53d1\u9001\n\n            // \u901a\u8fc7 mount \u9009\u9879\u53ef\u4ee5\u81ea\u5b9a\u4e49\u8f93\u5165\u6846\u6302\u8f7d\u7684\u4f4d\u7f6e\uff0c\u9ed8\u8ba4\u6302\u8f7d\u4e8e\u64ad\u653e\u5668\u5e95\u90e8\uff0c\u4ec5\u5728\u5f53\u5bbd\u5ea6\u5c0f\u4e8e\u6700\u5c0f\u503c\u65f6\u751f\u6548\n            // mount: document.querySelector('.artplayer-danmuku'),\n        }),\n    ],\n});\n")),(0,l.kt)("h3",{id:"\u4f7f\u7528\u5f39\u5e55-xml"},"\u4f7f\u7528\u5f39\u5e55 XML"),(0,l.kt)("div",{className:"run-code","data-libs":"./uncompiled/artplayer-plugin-danmuku/index.js"},"\u25b6 Run Code"),(0,l.kt)("pre",null,(0,l.kt)("code",{parentName:"pre",className:"language-js"},"var art = new Artplayer({\n    container: '.artplayer-app',\n    url: '/assets/sample/video.mp4',\n    plugins: [\n        artplayerPluginDanmuku({\n            // \u5f39\u5e55 XML \u6587\u4ef6\uff0c\u548c Bilibili \u7f51\u7ad9\u7684\u5f39\u5e55\u683c\u5f0f\u4e00\u81f4\n            danmuku: '/assets/sample/danmuku.xml',\n        }),\n    ],\n});\n")),(0,l.kt)("h3",{id:"\u4f7f\u7528\u5f02\u6b65\u8c03\u7528"},"\u4f7f\u7528\u5f02\u6b65\u8c03\u7528"),(0,l.kt)("div",{className:"run-code","data-libs":"./uncompiled/artplayer-plugin-danmuku/index.js"},"\u25b6 Run Code"),(0,l.kt)("pre",null,(0,l.kt)("code",{parentName:"pre",className:"language-js"},"var art = new Artplayer({\n    container: '.artplayer-app',\n    url: '/assets/sample/video.mp4',\n    plugins: [\n        artplayerPluginDanmuku({\n            // \u4f7f\u7528 Promise \u5f02\u6b65\u8fd4\u56de\n            danmuku: function () {\n                return new Promise((resovle) => {\n                    return resovle([\n                        {\n                            text: '111',\n                            time: 1,\n                        },\n                        {\n                            text: '222',\n                            time: 2,\n                        },\n                        {\n                            text: '333',\n                            time: 3,\n                        },\n                    ]);\n                });\n            },\n        }),\n    ],\n});\n")),(0,l.kt)("h2",{id:"\u63a5\u53e3"},"\u63a5\u53e3"),(0,l.kt)("h3",{id:"hideshow"},"hide/show"),(0,l.kt)("ul",null,(0,l.kt)("li",{parentName:"ul"},"\u7c7b\u578b: ",(0,l.kt)("inlineCode",{parentName:"li"},"Function"))),(0,l.kt)("p",null,"\u901a\u8fc7\u65b9\u6cd5 ",(0,l.kt)("inlineCode",{parentName:"p"},"hide")," \u548c ",(0,l.kt)("inlineCode",{parentName:"p"},"show")," \u8fdb\u884c\u9690\u85cf\u6216\u8005\u663e\u793a\u5f39\u5e55"),(0,l.kt)("div",{className:"run-code","data-libs":"./uncompiled/artplayer-plugin-danmuku/index.js"},"\u25b6 Run Code"),(0,l.kt)("pre",null,(0,l.kt)("code",{parentName:"pre",className:"language-js"},"var art = new Artplayer({\n    container: '.artplayer-app',\n    url: '/assets/sample/video.mp4',\n    plugins: [\n        artplayerPluginDanmuku({\n            danmuku: '/assets/sample/danmuku.xml',\n        }),\n    ],\n    controls: [\n        {\n            position: 'right',\n            html: '\u9690\u85cf\u5f39\u5e55',\n            click: function () {\n                art.plugins.artplayerPluginDanmuku.hide();\n            },\n        },\n        {\n            position: 'right',\n            html: '\u663e\u793a\u5f39\u5e55',\n            click: function () {\n                art.plugins.artplayerPluginDanmuku.show();\n            },\n        },\n    ],\n});\n")),(0,l.kt)("h3",{id:"ishide"},"isHide"),(0,l.kt)("ul",null,(0,l.kt)("li",{parentName:"ul"},"\u7c7b\u578b: ",(0,l.kt)("inlineCode",{parentName:"li"},"Boolean"))),(0,l.kt)("p",null,"\u901a\u8fc7\u5c5e\u6027 ",(0,l.kt)("inlineCode",{parentName:"p"},"isHide")," \u5224\u65ad\u5f53\u524d\u5f39\u5e55\u662f\u9690\u85cf\u6216\u8005\u663e\u793a"),(0,l.kt)("div",{className:"run-code","data-libs":"./uncompiled/artplayer-plugin-danmuku/index.js"},"\u25b6 Run Code"),(0,l.kt)("pre",null,(0,l.kt)("code",{parentName:"pre",className:"language-js"},"var art = new Artplayer({\n    container: '.artplayer-app',\n    url: '/assets/sample/video.mp4',\n    plugins: [\n        artplayerPluginDanmuku({\n            danmuku: '/assets/sample/danmuku.xml',\n        }),\n    ],\n    controls: [\n        {\n            position: 'right',\n            html: '\u9690\u85cf\u5f39\u5e55',\n            click: function (_, event) {\n                if (art.plugins.artplayerPluginDanmuku.isHide) {\n                    art.plugins.artplayerPluginDanmuku.show();\n                    event.target.innerText = '\u9690\u85cf\u5f39\u5e55';\n                } else {\n                    art.plugins.artplayerPluginDanmuku.hide();\n                    event.target.innerText = '\u663e\u793a\u5f39\u5e55';\n                }\n            },\n        },\n    ],\n});\n")),(0,l.kt)("h3",{id:"emit"},"emit"),(0,l.kt)("ul",null,(0,l.kt)("li",{parentName:"ul"},"\u7c7b\u578b: ",(0,l.kt)("inlineCode",{parentName:"li"},"Function"))),(0,l.kt)("p",null,"\u901a\u8fc7\u65b9\u6cd5 ",(0,l.kt)("inlineCode",{parentName:"p"},"emit")," \u53d1\u9001\u4e00\u6761\u5b9e\u65f6\u5f39\u5e55"),(0,l.kt)("div",{className:"run-code","data-libs":"./uncompiled/artplayer-plugin-danmuku/index.js"},"\u25b6 Run Code"),(0,l.kt)("pre",null,(0,l.kt)("code",{parentName:"pre",className:"language-js"},"var art = new Artplayer({\n    container: '.artplayer-app',\n    url: '/assets/sample/video.mp4',\n    plugins: [\n        artplayerPluginDanmuku({\n            danmuku: '/assets/sample/danmuku.xml',\n        }),\n    ],\n    controls: [\n        {\n            position: 'right',\n            html: '\u53d1\u9001\u5f39\u5e55',\n            click: function () {\n                var text = prompt('\u8bf7\u8f93\u5165\u5f39\u5e55\u6587\u672c', '\u5f39\u5e55\u6d4b\u8bd5\u6587\u672c');\n                if (!text || !text.trim()) return;\n                var color = '#' + Math.floor(Math.random() * 0xffffff).toString(16);\n                art.plugins.artplayerPluginDanmuku.emit({\n                    text: text,\n                    color: color,\n                    border: true,\n                });\n            },\n        },\n    ],\n});\n")),(0,l.kt)("h3",{id:"config"},"config"),(0,l.kt)("ul",null,(0,l.kt)("li",{parentName:"ul"},"\u7c7b\u578b: ",(0,l.kt)("inlineCode",{parentName:"li"},"Function"))),(0,l.kt)("p",null,"\u901a\u8fc7\u65b9\u6cd5 ",(0,l.kt)("inlineCode",{parentName:"p"},"config")," \u5b9e\u65f6\u6539\u53d8\u5f39\u5e55\u914d\u7f6e\uff0c\u652f\u6301\u5c5e\u6027\u6709\uff1a"),(0,l.kt)("ul",null,(0,l.kt)("li",{parentName:"ul"},"danmuku"),(0,l.kt)("li",{parentName:"ul"},"speed"),(0,l.kt)("li",{parentName:"ul"},"opacity"),(0,l.kt)("li",{parentName:"ul"},"fontSize"),(0,l.kt)("li",{parentName:"ul"},"color"),(0,l.kt)("li",{parentName:"ul"},"mode"),(0,l.kt)("li",{parentName:"ul"},"margin"),(0,l.kt)("li",{parentName:"ul"},"antiOverlap"),(0,l.kt)("li",{parentName:"ul"},"synchronousPlayback"),(0,l.kt)("li",{parentName:"ul"},"filter"),(0,l.kt)("li",{parentName:"ul"},"lockTime"),(0,l.kt)("li",{parentName:"ul"},"beforeEmit")),(0,l.kt)("div",{className:"run-code","data-libs":"./uncompiled/artplayer-plugin-danmuku/index.js"},"\u25b6 Run Code"),(0,l.kt)("pre",null,(0,l.kt)("code",{parentName:"pre",className:"language-js"},"var art = new Artplayer({\n    container: '.artplayer-app',\n    url: '/assets/sample/video.mp4',\n    plugins: [\n        artplayerPluginDanmuku({\n            danmuku: '/assets/sample/danmuku.xml',\n        }),\n    ],\n    controls: [\n        {\n            position: 'right',\n            html: '\u5f39\u5e55\u5927\u5c0f\uff1a<input type=\"range\" min=\"12\" max=\"50\" step=\"1\" value=\"25\">',\n            style: {\n                display: 'flex',\n                alignItems: 'center',\n            },\n            mounted: function ($setting) {\n                const $range = $setting.querySelector('input[type=range]');\n                $range.addEventListener('change', () => {\n                    art.plugins.artplayerPluginDanmuku.config({\n                        fontSize: Number($range.value),\n                    });\n                });\n            },\n        },\n    ],\n});\n")),(0,l.kt)("h3",{id:"load"},"load"),(0,l.kt)("ul",null,(0,l.kt)("li",{parentName:"ul"},"\u7c7b\u578b: ",(0,l.kt)("inlineCode",{parentName:"li"},"Function"))),(0,l.kt)("p",null,"\u901a\u8fc7 load \u65b9\u6cd5\u53ef\u4ee5\u91cd\u8f7d\u5f39\u5e55\u6e90\uff0c\u6216\u8005\u5207\u6362\u65b0\u5f39\u5e55"),(0,l.kt)("div",{className:"run-code","data-libs":"./uncompiled/artplayer-plugin-danmuku/index.js"},"\u25b6 Run Code"),(0,l.kt)("pre",null,(0,l.kt)("code",{parentName:"pre",className:"language-js"},"var art = new Artplayer({\n    container: '.artplayer-app',\n    url: '/assets/sample/video.mp4',\n    plugins: [\n        artplayerPluginDanmuku({\n            danmuku: '/assets/sample/danmuku.xml',\n        }),\n    ],\n    controls: [\n        {\n            position: 'right',\n            html: '\u91cd\u8f7d\u5f39\u5e55',\n            click: function () {\n                art.plugins.artplayerPluginDanmuku.load();\n            },\n        },\n        {\n            position: 'right',\n            html: '\u5207\u6362\u5f39\u5e55',\n            click: function () {\n                art.plugins.artplayerPluginDanmuku.config({\n                    danmuku: '/assets/sample/danmuku-v2.xml',\n                });\n                art.plugins.artplayerPluginDanmuku.load();\n            },\n        },\n    ],\n});\n")),(0,l.kt)("h2",{id:"\u4e8b\u4ef6"},"\u4e8b\u4ef6"),(0,l.kt)("pre",null,(0,l.kt)("code",{parentName:"pre",className:"language-js"},"var art = new Artplayer({\n    container: '.artplayer-app',\n    url: '/assets/sample/video.mp4',\n    setting: true,\n    plugins: [\n        artplayerPluginDanmuku({\n            danmuku: '/assets/sample/danmuku.xml',\n        }),\n    ],\n});\n\nart.on('artplayerPluginDanmuku:emit', (danmu) => {\n    console.info('\u65b0\u589e\u5f39\u5e55', danmu);\n});\n\nart.on('artplayerPluginDanmuku:loaded', (danmus) => {\n    console.info('\u52a0\u8f7d\u5f39\u5e55', danmus.length);\n});\n\nart.on('artplayerPluginDanmuku:error', (error) => {\n    console.info('\u52a0\u8f7d\u9519\u8bef', error);\n});\n\nart.on('artplayerPluginDanmuku:config', (option) => {\n    console.info('\u914d\u7f6e\u53d8\u5316', option);\n});\n\nart.on('artplayerPluginDanmuku:stop', () => {\n    console.info('\u5f39\u5e55\u505c\u6b62');\n});\n\nart.on('artplayerPluginDanmuku:start', () => {\n    console.info('\u5f39\u5e55\u5f00\u59cb');\n});\n\nart.on('artplayerPluginDanmuku:hide', () => {\n    console.info('\u5f39\u5e55\u9690\u85cf');\n});\n\nart.on('artplayerPluginDanmuku:show', () => {\n    console.info('\u5f39\u5e55\u663e\u793a');\n});\n\nart.on('artplayerPluginDanmuku:destroy', () => {\n    console.info('\u5f39\u5e55\u9500\u6bc1');\n});\n")))}c.isMDXComponent=!0}}]);