From 7f3b11685142318bea737e10519c0de6688d9c56 Mon Sep 17 00:00:00 2001 From: Harvey Date: Sun, 26 Apr 2020 08:59:30 +0800 Subject: [PATCH] Update danmuku.js --- docs/assets/example/danmuku.js | 53 +++++++++++++++++++++++++++------- 1 file changed, 43 insertions(+), 10 deletions(-) diff --git a/docs/assets/example/danmuku.js b/docs/assets/example/danmuku.js index e046c2d83..34b2f29d9 100644 --- a/docs/assets/example/danmuku.js +++ b/docs/assets/example/danmuku.js @@ -6,13 +6,46 @@ var art = new Artplayer({ setting: true, playbackRate: true, fullscreenWeb: true, - plugins: [artplayerPluginDanmuku({ - danmuku: url + '/danmuku/your-name.xml', - speed: 5, - maxlength: 50, - margin: [10, 100], - opacity: 1, - fontSize: 25, - synchronousPlayback: false, - })], -}); \ No newline at end of file + plugins: [ + artplayerPluginDanmuku({ + danmuku: url + '/danmuku/your-name.xml', + speed: 5, + maxlength: 50, + margin: [10, 100], + opacity: 1, + fontSize: 25, + synchronousPlayback: false, + }), + ], + controls: [ + { + position: 'right', + html: 'Hide', + click: function () { + art.plugins.artplayerPluginDanmuku.hide(); + }, + }, + { + position: 'right', + html: 'Show', + click: function () { + art.plugins.artplayerPluginDanmuku.show(); + }, + }, + { + position: 'right', + html: 'Send', + click: function () { + var text = prompt('Please enter', 'Danmu text'); + if (!text || !text.trim()) return; + var color = '#' + Math.floor(Math.random() * 0xffffff).toString(16); + art.plugins.artplayerPluginDanmuku.emit({ + text: text, + color: color, + border: color, + time: art.player.currentTime + 0.2, + }); + }, + }, + ], +});