add files

This commit is contained in:
Harvey Zack committed 2018-10-11 14:55:40 +08:00
1 parent 70864abf44
commit a53a1236a3
16 files changed
+581 -276

No files matched your search

+3 -3
View File
@@ -5,15 +5,15 @@ import JP from './jp';
const i18nMap = {
zh: ZHCN,
'zh-CN': ZHCN,
'zh-TW': ZHTW,
'zh-cn': ZHCN,
'zh-tw': ZHTW,
en: EN,
jp: JP
};
export default class I18n {
constructor({ option }) {
this.language = i18nMap[option.language] || i18nMap.en;
this.language = i18nMap[option.lang.toLowerCase()] || i18nMap.en;
}
get(key) {
+48 -6
View File
@@ -7,7 +7,7 @@ import Controls from './controls';
import Contextmenu from './contextmenu';
import Danmu from './danmu';
import Info from './info';
import Captions from './captions';
import Subtitle from './subtitle';
import Events from './events';
import Hotkey from './hotkey';
@@ -28,12 +28,55 @@ class Artplayer extends Emitter {
static get DEFAULTS() {
return {
//
container: document.querySelector('.artplayer'),
live: false,
autoplay: false,
theme: '#b7daff',
loop: false,
lang: navigator.language.toLowerCase(),
screenshot: false,
hotkey: true,
preload: 'auto',
volume: 0.7,
logo: '',
apiBackend: '',
video: {
quality: '',
defaultQuality: '',
url: '',
pic: '',
thumbnails: '',
type: 'auto',
customType: ''
},
subtitle: {
url: '',
type: 'webvtt',
fontSize: '20px',
bottom: '40px',
color: '#fff'
},
danmaku: {
id: '',
api: '',
token: '',
maximum: '',
addition: '',
user: '',
bottom: '',
unlimited: ''
},
contextmenu: [],
highlight: [],
mutex: true
};
}
init() {
this.refs = {};
this.refs = {
container: this.option.container
};
this.destroyEvents = [];
this.i18n = new I18n(this);
@@ -41,20 +84,19 @@ class Artplayer extends Emitter {
this.controls = new Controls(this);
this.contextmenu = new Contextmenu(this);
this.danmu = new Danmu(this);
this.captions = new Captions(this);
this.subtitle = new Subtitle(this);
this.info = new Info(this);
this.events = new Events(this);
this.hotkey = new Hotkey(this);
this.id = id++;
instances.push(this);
console.log(this);
}
destroy() {
this.destroyEvents.forEach(event => event.destroy());
this.refs.container.innerHTML = '';
instances.splice(instances.indexOf(this), 1);
}
}
View File
File renamed without changes.
+7
View File
@@ -0,0 +1,7 @@
export default class ArtPlayerError extends Error {
constructor(message) {
super(message);
Error.captureStackTrace(this, this.constructor);
this.name = 'ArtPlayerError';
}
}
View File
Whitespace-only changes.
+7
View File
@@ -1 +1,8 @@
import ArtPlayerError from './ArtPlayerError';
export * from './verification';
export function errorHandle(condition, msg) {
if (!condition) {
throw new ArtPlayerError(msg);
}
}
+3 -1
View File
@@ -1,3 +1,5 @@
import { errorHandle } from './index';
export function verification(option) {
//
console.log(option);
}