mirror of
https://github.com/zhw2590582/ArtPlayer.git
synced 2026-10-20 20:21:20 -08:00
add errorHandle
This commit is contained in:
1 parent
19a2636ea9
commit
b74ff6052c
4 files changed
+23
-18
No files matched your search
+1
-6
@@ -14,11 +14,6 @@ export default class Player {
|
||||
$video.volume = clamp(option.volume, 0, 1);
|
||||
$video.autoplay = option.autoplay;
|
||||
$video.preload = option.preload;
|
||||
|
||||
if (typeof option.url === 'string') {
|
||||
$video.src = option.url;
|
||||
} else if (Array.isArray(option.url)) {
|
||||
//
|
||||
}
|
||||
$video.src = option.url;
|
||||
}
|
||||
}
|
||||
@@ -1,9 +1,15 @@
|
||||
import { errorHandle } from './index';
|
||||
|
||||
export default function verification(option) {
|
||||
errorHandle(option.container, '\'container\' option is required.');
|
||||
errorHandle(
|
||||
option.container,
|
||||
'\'container\' option is required.'
|
||||
);
|
||||
|
||||
errorHandle(option.url, '\'url\' option is required.');
|
||||
errorHandle(
|
||||
option.url,
|
||||
'\'url\' option is required.'
|
||||
);
|
||||
|
||||
errorHandle(
|
||||
option.container instanceof Element,
|
||||
@@ -11,13 +17,13 @@ export default function verification(option) {
|
||||
);
|
||||
|
||||
errorHandle(
|
||||
typeof option.url === 'string' || Array.isArray(option.url),
|
||||
`'url' option require 'string' or 'array' type, but got '${typeof option.url}'.`
|
||||
typeof option.url === 'string',
|
||||
`'url' option require 'string' type, but got '${typeof option.url}'.`
|
||||
);
|
||||
|
||||
errorHandle(
|
||||
typeof option.poster === 'string',
|
||||
`'url' option require 'string' type, but got '${typeof option.poster}'.`
|
||||
`'poster' option require 'string' type, but got '${typeof option.poster}'.`
|
||||
);
|
||||
|
||||
errorHandle(
|
||||
@@ -34,4 +40,10 @@ export default function verification(option) {
|
||||
['none', 'metadata', 'auto'].indexOf(option.preload) > -1,
|
||||
'\'preload\' option require one of \'none、metadata、auto\'.'
|
||||
);
|
||||
|
||||
errorHandle(
|
||||
typeof option.lang === 'string',
|
||||
`'lang' option require 'string' type, but got '${typeof option.lang}'.`
|
||||
);
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user