MSE in switchVideo

This commit is contained in:
DIYgod 2017-09-03 04:00:13 +08:00
parent a3883ec046
commit 38c10cbd5a
No known key found for this signature in database
GPG Key ID: EC0B76A252D3EF67
5 changed files with 14 additions and 10 deletions

View File

@ -75,11 +75,10 @@
]
});
function switchDPlayer() {
if (dp2.option.danmaku.id !== '5rGf5Y2X55qu6Z2p') {
if (dp2.danmaku.options.api.id !== '5rGf5Y2X55qu6Z2p') {
dp2.switchVideo({
url: 'http://devtest.qiniudn.com/微小微-江南皮革厂倒闭了.mp4',
pic: 'http://devtest.qiniudn.com/微小微-江南皮革厂倒闭了.jpg',
type: 'auto',
url: 'http://devtest.qiniudn.com/若能绽放光芒5.m3u8',
type: 'hls'
},
{
id: '5rGf5Y2X55qu6Z2p',
@ -95,7 +94,7 @@
type: 'auto',
},
{
id: '9E2E3368B56CDBB42',
id: '9E2E3368B56CDBB4',
api: 'https://api.prprpr.me/dplayer/',
maximum: 3000,
user: 'DIYgod'

2
dist/DPlayer.min.js vendored

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1,6 +1,6 @@
{
"name": "dplayer",
"version": "1.8.0",
"version": "1.8.1",
"description": "Wow, such a lovely HTML5 danmaku video player",
"main": "dist/DPlayer.min.js",
"style": "dist/DPlayer.min.css",

View File

@ -920,9 +920,10 @@ class DPlayer {
* @param {Object} danmaku - new danmaku info
*/
switchVideo (video, danmakuAPI) {
this.pause();
this.video.poster = video.pic ? video.pic : '';
this.video.src = video.url;
this.pause();
this.initMSE(this.video, video.type || 'auto');
if (danmakuAPI) {
this.element.getElementsByClassName('dplayer-danloading')[0].style.display = 'block';
this.updateBar('played', 0, 'width');
@ -942,7 +943,7 @@ class DPlayer {
}
}
initVideo (video, type) {
initMSE (video, type) {
this.type = type;
if (this.type === 'auto') {
if (/m3u8(#|\?|$)/i.exec(video.src)) {
@ -973,6 +974,10 @@ class DPlayer {
flvPlayer.attachMediaElement(video);
flvPlayer.load();
}
}
initVideo (video, type) {
this.initMSE(video, type);
/**
* video events