DBplayer

阅读次数: 4,575

  • A+
所属分类:建站

 

Summary

 

Quick Start

<link rel="stylesheet" href="DPlayer.min.css">
<div id="dplayer"></div>
<script src="DPlayer.min.js"></script>
var dp = new DPlayer({
    element: document.getElementById('dplayer'),
    screenshot: true,
    video: {
        url: 'demo.mp4',
        pic: 'demo.jpg',
        thumbnails: 'thumbnails.jpg'
    },
    danmaku: {
        id: 'demo',
        api: 'https://api.prprpr.me/dplayer/'
    }
});

Options

var dp = new DPlayer({{
    element: document.getElementById('dplayer'),
    autoplay: false,
    theme: '#FADFA3',
    loop: true,
    screenshot: true,
    hotkey: true,
    logo: 'logo.png',
    volume: 0.2,
    video: {
        url: 'demo.mp4',
        pic: 'demo.png',
        thumbnails: 'thumbnails.jpg',
        type: 'auto'
    },
    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'
        }
    ]
});

Quality switching

var dp = new DPlayer({
    element: document.getElementById('dplayer'),
    video: {
        quality: [{
            name: 'HD',
            url: 'demo.m3u8',
            type: 'hls'
        }, {
            name: 'SD',
            url: 'demo.mp4',
            type: 'normal'
        }],
        defaultQuality: 0
    }
});

HLS support

It requires the library hls.js and it should be loaded before DPlayer.min.js.

<link rel="stylesheet" href="DPlayer.min.css">
<div id="dplayer"></div>
<script src="hls.min.js"></script>
<script src="DPlayer.min.js"></script>
var dp = new DPlayer({
    element: document.getElementById('dplayer'),
    video: {
        url: 'demo.m3u8',
        type: 'hls'
    }
});
// Another way, init HLS outside
var dp = new DPlayer({
    element: document.getElementById('dplayer')
});
var hls = new Hls();
hls.loadSource('demo.m3u8');
hls.attachMedia(dp.video);

FLV support

It requires the library flv.js and it should be loaded before DPlayer.min.js.

<link rel="stylesheet" href="DPlayer.min.css">
<div id="dplayer"></div>
<script src="flv.min.js"></script>
<script src="DPlayer.min.js"></script>
var dp = new DPlayer({
    element: document.getElementById('dplayer'),
    video: {
        url: 'demo.flv',
        type: 'flv'
    }
});
// Another way, init FLV outside
var dp = new DPlayer({
    element: document.getElementById('dplayer')
});
var flvPlayer = flvjs.createPlayer({
    type: 'flv',
    url: 'demo.flv'
});
flvPlayer.attachMediaElement(dp.video);
flvPlayer.load();

Bilibili video and danmaku

var dp = new DPlayer({
    element: document.getElementById('dplayer'),
    screenshot: false,
    video: {
        url: 'https://api.prprpr.me/dplayer/video/bilibili?aid=[aid]'
    },
    danmaku: {
        id: 'demo',
        api: 'https://api.prprpr.me/dplayer/',
        addition: ['https://api.prprpr.me/dplayer/bilibili?aid=[aid]']
    }
});

HTML5 check

  • Video
  • SVG
  • CSS animations
  • CSS transforms
  • Document fragment
  • Fullscreen
  • Localstorage
  • Canvas
  • Track
  • WebSockets

  • 我的微信
  • 这是我的微信扫一扫
  • weinxin
  • 我的微信公众号
  • 我的微信公众号扫一扫
  • weinxin
  • 版权声明:本站原创文章,于2017年9月8日00:03:44,由 发表,共 3267 字。
  • 转载请注明:DBplayer | 时刻需

发表评论

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: