From 98524855ed56c4a27fd4372d2edaab9ffcc06cd4 Mon Sep 17 00:00:00 2001 From: nklhrstv Date: Tue, 10 Mar 2020 17:50:05 +0200 Subject: [PATCH] subtitles settings linked with core --- src/routes/Player/Player.js | 22 ++++++++++++++++-- src/routes/Player/Video/Video.js | 27 ++++++++++++----------- src/routes/Player/useSubtitlesSettings.js | 24 +++++++++++++++----- 3 files changed, 53 insertions(+), 20 deletions(-) diff --git a/src/routes/Player/Player.js b/src/routes/Player/Player.js index c183f74b2..3daba9872 100644 --- a/src/routes/Player/Player.js +++ b/src/routes/Player/Player.js @@ -7,10 +7,12 @@ const ControlBar = require('./ControlBar'); const SubtitlesPicker = require('./SubtitlesPicker'); const Video = require('./Video'); const usePlayer = require('./usePlayer'); +const useSubtitlesSettings = require('./useSubtitlesSettings'); const styles = require('./styles'); const Player = ({ urlParams }) => { const player = usePlayer(urlParams); + const [subtitlesSettings, updateSubtitlesSettings] = useSubtitlesSettings(); const [subtitlesPickerOpen, , closeSubtitlesPicker, toggleSubtitlesPicker] = useBinaryState(true); const [state, setState] = React.useReducer( (state, nextState) => ({ @@ -44,7 +46,11 @@ const Player = ({ urlParams }) => { manifest.props.forEach((propName) => { dispatch({ observedPropName: propName }); }); - }, []); + dispatch({ propName: 'subtitlesSize', propValue: subtitlesSettings.size }); + dispatch({ propName: 'subtitlesTextColor', propValue: subtitlesSettings.text_color }); + dispatch({ propName: 'subtitlesBackgroundColor', propValue: subtitlesSettings.background_color }); + dispatch({ propName: 'subtitlesOutlineColor', propValue: subtitlesSettings.outline_color }); + }, [subtitlesSettings.size, subtitlesSettings.text_color, subtitlesSettings.background_color, subtitlesSettings.outline_color]); const onPropChanged = React.useCallback((propName, propValue) => { setState({ [propName]: propValue }); }, []); @@ -79,7 +85,7 @@ const Player = ({ urlParams }) => { dispatch({ propName: 'subtitlesDelay', propValue: delay }); }, []); const onSubtitlesSizeChanged = React.useCallback((size) => { - dispatch({ propName: 'subtitlesSize', propValue: size }); + updateSubtitlesSettings({ subtitles_size: size }); }, []); const onSubtitlesOffsetChanged = React.useCallback((offset) => { dispatch({ propName: 'subtitlesOffset', propValue: offset }); @@ -113,6 +119,18 @@ const Player = ({ urlParams }) => { } }); }, [player.subtitles_resources]); + React.useEffect(() => { + dispatch({ propName: 'subtitlesSize', propValue: subtitlesSettings.size }); + }, [subtitlesSettings.size]); + React.useEffect(() => { + dispatch({ propName: 'subtitlesTextColor', propValue: subtitlesSettings.text_color }); + }, [subtitlesSettings.text_color]); + React.useEffect(() => { + dispatch({ propName: 'subtitlesBackgroundColor', propValue: subtitlesSettings.background_color }); + }, [subtitlesSettings.background_color]); + React.useEffect(() => { + dispatch({ propName: 'subtitlesOutlineColor', propValue: subtitlesSettings.outline_color }); + }, [subtitlesSettings.outline_color]); return (