@@ -9,88 +9,89 @@ let browserCache;
99const _StoreData = { } ;
1010
1111class VideoPlayerStore extends EventEmitter {
12- constructor ( ) {
13- super ( ) ;
12+ constructor ( ) {
13+ super ( ) ;
1414
15- this . mediacms_config = mediacmsConfig ( window . MediaCMS ) ;
15+ this . mediacms_config = mediacmsConfig ( window . MediaCMS ) ;
1616
17- browserCache = new BrowserCache ( this . mediacms_config . site . id , 86400 ) ; // Keep cache data "fresh" for one day.
17+ browserCache = new BrowserCache ( this . mediacms_config . site . id , 86400 ) ; // Keep cache data "fresh" for one day.
1818
19- _StoreData . inTheaterMode = browserCache . get ( 'in-theater-mode' ) ;
20- _StoreData . inTheaterMode = null !== _StoreData . inTheaterMode ? _StoreData . inTheaterMode : ! 1 ;
19+ _StoreData . inTheaterMode = browserCache . get ( 'in-theater-mode' ) ;
20+ _StoreData . inTheaterMode = null !== _StoreData . inTheaterMode ? _StoreData . inTheaterMode : ! 1 ;
2121
22- _StoreData . playerVolume = browserCache . get ( 'player-volume' ) ;
23- _StoreData . playerVolume =
24- null === _StoreData . playerVolume ? 1 : Math . max ( Math . min ( Number ( _StoreData . playerVolume ) , 1 ) , 0 ) ;
22+ _StoreData . playerVolume = browserCache . get ( 'player-volume' ) ;
23+ _StoreData . playerVolume =
24+ null === _StoreData . playerVolume ? 1 : Math . max ( Math . min ( Number ( _StoreData . playerVolume ) , 1 ) , 0 ) ;
2525
26- _StoreData . playerSoundMuted = browserCache . get ( 'player-sound-muted' ) ;
27- _StoreData . playerSoundMuted = null !== _StoreData . playerSoundMuted ? _StoreData . playerSoundMuted : ! 1 ;
26+ _StoreData . playerSoundMuted = browserCache . get ( 'player-sound-muted' ) ;
27+ _StoreData . playerSoundMuted = null !== _StoreData . playerSoundMuted ? _StoreData . playerSoundMuted : ! 1 ;
2828
29- _StoreData . videoQuality = browserCache . get ( 'video-quality' ) ;
30- _StoreData . videoQuality = null !== _StoreData . videoQuality ? _StoreData . videoQuality : 'Auto' ;
29+ _StoreData . videoQuality = browserCache . get ( 'video-quality' ) ;
30+ _StoreData . videoQuality = null !== _StoreData . videoQuality ? _StoreData . videoQuality : 'Auto' ;
3131
32- _StoreData . videoPlaybackSpeed = browserCache . get ( 'video-playback-speed' ) ;
33- _StoreData . videoPlaybackSpeed = null !== _StoreData . videoPlaybackSpeed ? _StoreData . videoPlaybackSpeed : ! 1 ;
34- }
32+ _StoreData . videoPlaybackSpeed = browserCache . get ( 'video-playback-speed' ) ;
33+ _StoreData . videoPlaybackSpeed = null !== _StoreData . videoPlaybackSpeed ? _StoreData . videoPlaybackSpeed : ! 1 ;
34+ }
3535
36- get ( type ) {
37- let r = null ;
38- switch ( type ) {
39- case 'player-volume' :
40- r = _StoreData . playerVolume ;
41- break ;
42- case 'player-sound-muted' :
43- r = _StoreData . playerSoundMuted ;
44- break ;
45- case 'in-theater-mode' :
46- r = _StoreData . inTheaterMode ;
47- break ;
48- case 'video-data' :
49- r = _StoreData . videoData ;
50- break ;
51- case 'video-quality' :
52- r = _StoreData . videoQuality ;
53- break ;
54- case 'video-playback-speed' :
55- r = _StoreData . videoPlaybackSpeed ;
56- break ;
36+ get ( type ) {
37+ let r = null ;
38+ switch ( type ) {
39+ case 'player-volume' :
40+ r = _StoreData . playerVolume ;
41+ break ;
42+ case 'player-sound-muted' :
43+ r = _StoreData . playerSoundMuted ;
44+ break ;
45+ case 'in-theater-mode' :
46+ r = _StoreData . inTheaterMode ;
47+ break ;
48+ case 'video-data' :
49+ r = _StoreData . videoData ;
50+ break ;
51+ case 'video-quality' :
52+ r = _StoreData . videoQuality ;
53+ break ;
54+ case 'video-playback-speed' :
55+ r = _StoreData . videoPlaybackSpeed ;
56+ break ;
57+ }
58+ return r ;
5759 }
58- return r ;
59- }
6060
61- actions_handler ( action ) {
62- switch ( action . type ) {
63- case 'TOGGLE_VIEWER_MODE' :
64- _StoreData . inTheaterMode = ! _StoreData . inTheaterMode ;
65- this . emit ( 'changed_viewer_mode' ) ;
66- break ;
67- case 'SET_VIEWER_MODE' :
68- _StoreData . inTheaterMode = action . inTheaterMode ;
69- browserCache . set ( 'in-theater-mode' , _StoreData . inTheaterMode ) ;
70- this . emit ( 'changed_viewer_mode' ) ;
71- break ;
72- case 'SET_PLAYER_VOLUME' :
73- _StoreData . playerVolume = action . playerVolume ;
74- browserCache . set ( 'player-volume' , action . playerVolume ) ;
75- this . emit ( 'changed_player_volume' ) ;
76- break ;
77- case 'SET_PLAYER_SOUND_MUTED' :
78- _StoreData . playerSoundMuted = action . playerSoundMuted ;
79- browserCache . set ( 'player-sound-muted' , action . playerSoundMuted ) ;
80- this . emit ( 'changed_player_sound_muted' ) ;
81- break ;
82- case 'SET_VIDEO_QUALITY' :
83- _StoreData . videoQuality = action . quality ;
84- browserCache . set ( 'video-quality' , action . quality ) ;
85- this . emit ( 'changed_video_quality' ) ;
86- break ;
87- case 'SET_VIDEO_PLAYBACK_SPEED' :
88- _StoreData . videoPlaybackSpeed = action . playbackSpeed ;
89- browserCache . set ( 'video-playback-speed' , action . playbackSpeed ) ;
90- this . emit ( 'changed_video_playback_speed' ) ;
91- break ;
61+ actions_handler ( action ) {
62+ switch ( action . type ) {
63+ case 'TOGGLE_VIEWER_MODE' :
64+ _StoreData . inTheaterMode = ! _StoreData . inTheaterMode ;
65+ browserCache . set ( 'in-theater-mode' , _StoreData . inTheaterMode ) ;
66+ this . emit ( 'changed_viewer_mode' ) ;
67+ break ;
68+ case 'SET_VIEWER_MODE' :
69+ _StoreData . inTheaterMode = action . inTheaterMode ;
70+ browserCache . set ( 'in-theater-mode' , _StoreData . inTheaterMode ) ;
71+ this . emit ( 'changed_viewer_mode' ) ;
72+ break ;
73+ case 'SET_PLAYER_VOLUME' :
74+ _StoreData . playerVolume = action . playerVolume ;
75+ browserCache . set ( 'player-volume' , action . playerVolume ) ;
76+ this . emit ( 'changed_player_volume' ) ;
77+ break ;
78+ case 'SET_PLAYER_SOUND_MUTED' :
79+ _StoreData . playerSoundMuted = action . playerSoundMuted ;
80+ browserCache . set ( 'player-sound-muted' , action . playerSoundMuted ) ;
81+ this . emit ( 'changed_player_sound_muted' ) ;
82+ break ;
83+ case 'SET_VIDEO_QUALITY' :
84+ _StoreData . videoQuality = action . quality ;
85+ browserCache . set ( 'video-quality' , action . quality ) ;
86+ this . emit ( 'changed_video_quality' ) ;
87+ break ;
88+ case 'SET_VIDEO_PLAYBACK_SPEED' :
89+ _StoreData . videoPlaybackSpeed = action . playbackSpeed ;
90+ browserCache . set ( 'video-playback-speed' , action . playbackSpeed ) ;
91+ this . emit ( 'changed_video_playback_speed' ) ;
92+ break ;
93+ }
9294 }
93- }
9495}
9596
9697export default exportStore ( new VideoPlayerStore ( ) , 'actions_handler' ) ;
0 commit comments