• Stars
    star
    207
  • Rank 189,201 (Top 4 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created about 8 years ago
  • Updated over 6 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Embed dplayer in Hexo posts/pages

hexo-tag-dplayer

本项目是将diygod的dplayer运行在hexo的插件

感谢关注这个插件的人们,感谢aplayer的hexo插件作者@grzhan,感谢A or D播放器作者@Diygod

感谢插件豆子@dixyes的移植

借鉴项目:https://github.com/grzhan/hexo-tag-aplayer

这个项目的两个维护者一个只会卖萌,一个又沉迷屁股(这是豆子)

所以有什么bug很长时间没解决的,请谅解

如果您能修复的话,也希望请您修复一下提交个pr什么的,祝君安康


Embed DPlayer(https://github.com/DIYgod/DPlayer) in Hexo posts/pages.

Hexo Demo

plugin screenshot

npm install

npm install hexo-tag-dplayer --save

Usage

{% dplayer key=value ... %}

key can be

dplayer options:
    'autoplay', 'loop', 'screenshot', 'hotkey', 'mutex', 'dmunlimited' : bool options, use "yes" "y" "true" "1" "on" or just without value to enable
    'preload', 'theme', 'lang', 'logo', 'url', 'pic', 'thumbnails', 'vidtype', 'suburl', 'subtype', 'subbottom', 'subcolor', 'subcolor', 'id', 'api', 'token', 'addition', 'dmuser' : string arguments
    'volume', 'maximum' : number arguments
container options:
    'width', 'height' : string, used in container element style
other:
    'code' : value of this key will be append to script tag

arguments to DPlayer options mapping:

{
    container: "you needn't set this",
    autoplay: 'autoplay',
    theme: 'theme',
    loop: 'loop',
    lang: 'lang',
    screenshot: 'screenshot',
    hotkey: 'hotkey',
    preload: 'preload',
    logo: 'logo',
    volume: 'volume',
    mutex: 'mutex',
    video: {
        url: 'url',
        pic: 'pic',
        thumbnails: 'thumbnails',
        type: 'vidtype',
    },
    subtitle: {
        url: 'suburl',
        type: 'subtype',
        fontSize: 'subsize',
        bottom: 'subbottom',
        color: 'subcolor',
    },
    danmaku: {
        id: 'id',
        api: 'api',
        token: 'token',
        maximum: 'maximum',
        addition: ['addition'],
        user: 'dmuser',
        unlimited: 'dmunlimited',
    },
    icons: 'icons',
    contextmenu: 'menu',
}

see dplayer documents for more infomation.

for example:

{% dplayer "url=https://moeplayer.b0.upaiyun.com/dplayer/hikarunara.mp4" "addition=https://dplayer.daoapp.io/bilibili?aid=4157142" "api=https://api.prprpr.me/dplayer/" "pic=https://moeplayer.b0.upaiyun.com/dplayer/hikarunara.jpg" "id=9E2E3368B56CDBB4" "loop=yes" "theme=#FADFA3" "autoplay=false" "token=tokendemo" %}
{% dplayer 'url=some.mp4' "id=someid" "api=https://api.prprpr.me/dplayer/" "addition=/some.json" 'code=player.on("loadstart",function(){console.log("loadstart")})' "autoplay" %} 

PJAX compatible

$(document).on('pjax:start', function () {
    if (window.dplayers) {
        for (let i = 0; i < window.dplayers.length; i++) {
            window.dplayers[i].destroy();
        }
        window.dplayers = [];
    }
});

Customization

You can modify variables scriptDir(default: "/assets/js/" ) and styleDir(default: "/assets/css/") in index.js according to your blog's directory structure.

or just use _config.yml configuration:

# on _config.yml of hexo-site
hexo-tag-dplayer:
  js_path: /path/to/your/default/path
  css_path: /sth
  default: #default tag argument 
    id: somedefid # equals to setting id=somedefid in all {%dplayer%} tags
    api: https://api.prprpr.me/dplayer/
    #and other options...

Issue

If any issue occurs, tell me via issue, use a hexo raw tag like below to use dplayer:

{% raw %}
<div id="player1" class="dplayer"></div>
<script src="dist/DPlayer.min.js"></script><!-- use your path -->
<script>
var dp = new DPlayer({{
    container: document.getElementById('dplayer'),
    autoplay: false,
    theme: '#FADFA3',
    loop: true,
    screenshot: true,
    hotkey: true,
    logo: 'logo.png',
    volume: 0.2,
    mutex: true,
    video: {
        url: 'demo.mp4',
        pic: 'demo.png',
        thumbnails: 'thumbnails.jpg',
        type: 'auto'
    },
    subtitle: {
        url: 'webvtt.vtt',
        type: 'webvtt',
        fontSize: '25px',
        bottom: '10%',
        color: '#b7daff'
    },
    danmaku: {
        id: 'demo',
        api: 'https://api.prprpr.me/dplayer/',
        token: 'demo',
        maximum: 3000,
        user: 'DIYgod',
        margin: {
            bottom: '15%'
        },
        unlimited: true
    },
    contextmenu: [
        {
            text: 'custom contextmenu',
            link: 'https://github.com/MoePlayer/DPlayer'
        }
    ]
});
</script>
{% endraw %}

see DPlayer for usage detail

Todo

LICENSE

MIT

More Repositories

1

hexo-tag-aplayer

Embed aplayer in Hexo posts/pages
JavaScript
702
star
2

cPlayer

A beautiful and clean WEB Music Player by HTML5.
CSS
667
star
3

vue-dplayer

📹 A Vue 2.x video player component based on DPlayer
Vue
620
star
4

APlayer-Typecho

在线音乐播放器插件 for typecho 1.0
PHP
486
star
5

vue-aplayer

🍰 A beautiful HTML5 music player for Vue.js
TypeScript
462
star
6

Hermit-X

在 WordPress 中使用 APlayer 播放音乐吧~
JavaScript
289
star
7

DPlayer-Typecho

Typecho plugin for DPlayer
PHP
191
star
8

DPlayer-node

Node.js backend with Docker for DPlayer(https://github.com/DIYgod/DPlayer)
JavaScript
164
star
9

react-dplayer

react-dplayer
JavaScript
150
star
10

DPlayer-WordPress

DPlayer for WordPress
PHP
69
star
11

DPlayer-thumbnails

Generate thumbnails for DPlayer
JavaScript
63
star
12

react-aplayer

🍭 A React wrapper component of APlayer
JavaScript
39
star
13

laravel-danmaku

DPlayer Danmaku
PHP
29
star
14

angular-moeplayer

An Angular 6.x video player component based on DPlayer
TypeScript
29
star
15

DPlayer-data

DPlayer damaku data daily backup
Shell
19
star
16

Caraoke

Web Karaoke Loader,shows karaoke lyrics in web pages.
TypeScript
11
star
17

DPlayer_for_Z-BlogPHP

Z-BlogPHP plugin for DPlayer https://www.fghrsh.net/post/57.html
PHP
9
star
18

APlayer_for_Z-BlogPHP

Z-BlogPHP plugin for APlayer https://www.fghrsh.net/post/77.html
PHP
8
star
19

DPlayer-API

DPlayer API For PHP
PHP
8
star
20

DPlayer-Chrome

Replace stupid players with DPlayer
7
star
21

RailsGun

🔫 Dplayer backend for rails 弹幕军火库。姬~~。。 超电磁炮!!!
Ruby
6
star
22

MoePlayer.github.io

Homepage for MoePlayer
HTML
5
star