Skip to content

Commit db477ea

Browse files
authored
Merge pull request #67 from draku29/refactor/constants
Refactor/constants
2 parents 57f173b + 8a17138 commit db477ea

File tree

2 files changed

+32
-12
lines changed

2 files changed

+32
-12
lines changed

index.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
import YoutubeIframe from './src/YoutubeIframe';
22
import {getYoutubeMeta} from './src/oEmbed';
3+
import {
4+
PLAYER_STATES_NAMES as PLAYER_STATES,
5+
PLAYER_ERROR_NAMES as PLAYER_ERRORS,
6+
} from './src/constants';
37

48
export default YoutubeIframe;
5-
export {getYoutubeMeta};
9+
export {getYoutubeMeta, PLAYER_STATES, PLAYER_ERRORS};

src/constants.js

Lines changed: 27 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,34 @@
1+
export const PLAYER_STATES_NAMES = {
2+
UNSTARTED: 'unstarted',
3+
ENDED: 'ended',
4+
PLAYING: 'playing',
5+
PAUSED: 'paused',
6+
BUFFERING: 'buffering',
7+
VIDEO_CUED: 'video cued',
8+
};
9+
110
export const PLAYER_STATES = {
2-
'-1': 'unstarted',
3-
'0': 'ended',
4-
'1': 'playing',
5-
'2': 'paused',
6-
'3': 'buffering',
7-
'5': 'video cued',
11+
'-1': PLAYER_STATES_NAMES.UNSTARTED,
12+
'0': PLAYER_STATES_NAMES.ENDED,
13+
'1': PLAYER_STATES_NAMES.PLAYING,
14+
'2': PLAYER_STATES_NAMES.PAUSED,
15+
'3': PLAYER_STATES_NAMES.BUFFERING,
16+
'5': PLAYER_STATES_NAMES.VIDEO_CUED,
17+
};
18+
19+
export const PLAYER_ERROR_NAMES = {
20+
INVALID_PARAMETER: 'invalid_parameter',
21+
HTML5_ERROR: 'HTML5_error',
22+
VIDEO_NOT_FOUND: 'video_not_found',
23+
EMBED_NOT_ALLOWED: 'embed_not_allowed',
824
};
925

1026
export const PLAYER_ERROR = {
11-
'2': 'invalid_parameter',
12-
'5': 'HTML5_error',
13-
'100': 'video_not_found',
14-
'101': 'embed_not_allowed',
15-
'150': 'embed_not_allowed',
27+
'2': PLAYER_ERROR_NAMES.INVALID_PARAMETER,
28+
'5': PLAYER_ERROR_NAMES.HTML5_ERROR,
29+
'100': PLAYER_ERROR_NAMES.VIDEO_NOT_FOUND,
30+
'101': PLAYER_ERROR_NAMES.EMBED_NOT_ALLOWED,
31+
'150': PLAYER_ERROR_NAMES.EMBED_NOT_ALLOWED,
1632
};
1733

1834
export const CUSTOM_USER_AGENT =

0 commit comments

Comments
 (0)