MPEG DASH support

This commit is contained in:
DIYgod
2017-09-26 01:51:33 +08:00
parent d8cfa122b2
commit c0f515addb
6 changed files with 38 additions and 8 deletions
+2 -1
View File
@@ -55,6 +55,7 @@
"require": false,
"module": false,
"Hls": false,
"flvjs": false
"flvjs": false,
"dashjs": false
}
}
+21
View File
@@ -9,6 +9,7 @@
<link rel="stylesheet" href="demo.css">
<script src="https://unpkg.com/flv.js/dist/flv.min.js"></script>
<script src="https://unpkg.com/hls.js/dist/hls.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/dashjs/dist/dash.all.min.js"></script>
<script src="DPlayer.js"></script>
</head>
@@ -215,6 +216,26 @@
flvPlayer.load();
</script>
</div>
<h2 id="dash-support">MPEG DASH support</h2>
<div class="example">
<div id="dplayer10"></div>
<script>
var dp10 = new DPlayer({
container: document.getElementById('dplayer10'),
video: {
url: 'http://devtest.qiniudn.com/若能绽放光芒.mpd',
type: 'dash'
}
});
</script>
<div id="dplayer11"></div>
<script>
var dp11 = new DPlayer({
container: document.getElementById('dplayer11')
});
dashjs.MediaPlayer().create().initialize(dp11.video, "http://devtest.qiniudn.com/若能绽放光芒.mpd", false);
</script>
</div>
<h2 id="bilibili-video-and-danmaku">Bilibili video and danmaku</h2>
<div class="example">
+1 -1
View File
File diff suppressed because one or more lines are too long
+1 -1
View File
File diff suppressed because one or more lines are too long
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "dplayer",
"version": "1.15.1",
"version": "1.16.0",
"description": "Wow, such a lovely HTML5 danmaku video player",
"main": "dist/DPlayer.min.js",
"style": "dist/DPlayer.min.css",
+12 -4
View File
@@ -951,21 +951,24 @@ class DPlayer {
else if (/.flv(#|\?|$)/i.exec(video.src)) {
this.type = 'flv';
}
else if (/.mpd(#|\?|$)/i.exec(video.src)) {
this.type = 'dash';
}
else {
this.type = 'normal';
}
}
// Support HTTP Live Streaming
if (this.type === 'hls' && Hls.isSupported()) {
// HTTP Live Streaming
if (this.type === 'hls' && Hls && Hls.isSupported()) {
// this.container.getElementsByClassName('dplayer-time')[0].style.display = 'none';
const hls = new Hls();
hls.loadSource(video.src);
hls.attachMedia(video);
}
// Support FLV
if (this.type === 'flv' && flvjs.isSupported()) {
// FLV
if (this.type === 'flv' && flvjs && flvjs.isSupported()) {
const flvPlayer = flvjs.createPlayer({
type: 'flv',
url: video.src
@@ -973,6 +976,11 @@ class DPlayer {
flvPlayer.attachMediaElement(video);
flvPlayer.load();
}
// MPEG DASH
if (this.type === 'dash' && dashjs) {
dashjs.MediaPlayer().create().initialize(video, video.src, false);
}
}
initVideo (video, type) {