update README: bilibili 弹幕及直链支持

This commit is contained in:
DIYgod 2016-10-20 02:15:03 +08:00
parent dda08cb959
commit 102f47f3d2
No known key found for this signature in database
GPG Key ID: F8797DD1088C6506

View File

@ -94,7 +94,11 @@ var option = {
+ `ended`: Triggered when DPlayer ended
+ `error`: Triggered when an error occurs
**Bilibili 弹幕支持**
**bilibili 弹幕及直链支持**
弹幕
API: `https://dplayer.daoapp.io/bilibili?aid=【bilibili视频AV号】`
```JS
var option = {
@ -105,6 +109,34 @@ var option = {
}
```
直链
API: `https://dplayer.daoapp.io/video/bilibili?aid=【bilibili视频AV号】`
```JS
var xhr = new XMLHttpRequest();
xhr.onreadystatechange = function () {
    if (xhr.readyState === 4) {
        if (xhr.status >= 200 && xhr.status < 300 || xhr.status === 304) {
            var response = JSON.parse(xhr.responseText);
            var dp1 = new DPlayer({
                // options
                screenshot: false,
                video: {
                    url: response.durl[0].url
                    // options
                }
            });
        }
        else {
            console.log('Request was unsuccessful: ' + xhr.status);
        }
    }
};
xhr.open('get', 'https://dplayer.daoapp.io/video/bilibili?aid=【bilibili视频AV号】', true);
xhr.send(null);
```
**Live Video (HTTP Live Streaming, M3U8 format)**
It requires the library [hls.js](https://github.com/dailymotion/hls.js) and it should be loaded before DPlayer.min.js.