This commit is contained in:
Harvey Zack committed 2018-12-14 14:10:39 +08:00
1 parent 9f90774b4f
commit 3f451aa047
12 files changed
+191 -147

No files matched your search

+5 -1
View File
@@ -1,5 +1,9 @@
function artplayerPluginFlv(art) {
console.log(art);
return {
attach: url => new Promise(resolve => {
resolve('https://blog.zhw-island.com/assets-cdn/video/one-more-time-one-more-chance-480p.mp4');
}),
};
}
window.artplayerPluginFlv = artplayerPluginFlv;
-2
View File
@@ -9,7 +9,6 @@ import Whitelist from './whitelist';
import Template from './template';
import I18n from './i18n';
import Player from './player';
import Mse from './mse';
import Controls from './controls';
import Contextmenu from './contextmenu';
import Info from './info';
@@ -116,7 +115,6 @@ class Artplayer extends Emitter {
this.notice = new Notice(this);
this.events = new Events(this);
this.player = new Player(this);
this.mse = new Mse(this);
this.layers = new Layers(this);
this.controls = new Controls(this);
this.contextmenu = new Contextmenu(this);
+13 -19
View File
@@ -6,37 +6,31 @@ export default function attachUrlMix(art, player) {
template: { $video },
} = art;
Object.defineProperty(player, 'returnUrl', {
writable: true,
value: url => url,
});
Object.defineProperty(player, 'attachUrl', {
value: url => {
value: url => sleep().then(() => {
function attachUrl(videoUrl) {
const typeName = type || getExt(videoUrl);
const typeCallback = customType[typeName];
return sleep().then(() => {
if (typeName && typeCallback) {
art.emit('beforeCustomType', typeName);
typeCallback($video, player.returnUrl(videoUrl), art);
art.emit('afterCustomType', typeName);
} else {
art.emit('beforeAttachUrl', videoUrl);
$video.src = player.returnUrl(videoUrl);
art.emit('afterAttachUrl', $video.src);
}
});
if (typeName && typeCallback) {
art.emit('beforeCustomType', typeName);
typeCallback.call(art, $video, videoUrl, art);
art.emit('afterCustomType', typeName);
} else {
art.emit('beforeAttachUrl', videoUrl);
$video.src = videoUrl;
art.emit('afterAttachUrl', videoUrl);
}
return Promise.resolve(videoUrl);
}
if (typeof url === 'function') {
return url().then(videoUrl => {
return url.call(art).then(videoUrl => {
art.loading.show();
return attachUrl(videoUrl);
});
}
return attachUrl(url);
},
}),
});
}