-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
add CC button component add `showCCButton` option to the ui config (default `false`) add `UIElementClickedEvent` event for generic element click Solves FEC-12015
- Loading branch information
Showing
16 changed files
with
181 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
.control-button-container.control-closed-captions .control-button { | ||
.icon-closed-captions-on { | ||
display: none; | ||
} | ||
|
||
&.cc-on { | ||
.icon-closed-captions-off { | ||
display: none; | ||
} | ||
.icon-closed-captions-on { | ||
display: block; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
//@flow | ||
import style from '../../styles/style.scss'; | ||
import {h} from 'preact'; | ||
import {useEffect, useState} from 'preact/hooks'; | ||
import {withText} from 'preact-i18n'; | ||
import {default as Icon, IconType} from '../icon'; | ||
import {connect} from 'react-redux'; | ||
import {withEventDispatcher} from 'components/event-dispatcher'; | ||
import {withLogger} from 'components/logger'; | ||
import {Tooltip} from 'components/tooltip'; | ||
import {Button} from 'components/button'; | ||
import {ButtonControl} from 'components/button-control'; | ||
/** | ||
* mapping state to props | ||
* @param {*} state - redux store state | ||
* @returns {Object} - mapped state to this component | ||
*/ | ||
const mapStateToProps = state => ({ | ||
textTracks: state.engine.textTracks, | ||
showCCButton: state.config.showCCButton | ||
}); | ||
|
||
const COMPONENT_NAME = 'ClosedCaptions'; | ||
|
||
/** | ||
* ClosedCaptions component | ||
* | ||
* @class ClosedCaptions | ||
* @example <ClosedCaptions /> | ||
* @extends {Component} | ||
*/ | ||
const ClosedCaptions = connect(mapStateToProps)( | ||
withLogger(COMPONENT_NAME)( | ||
withEventDispatcher(COMPONENT_NAME)( | ||
withText({ | ||
closedCaptionsOnText: 'controls.closedCaptionsOn', | ||
closedCaptionsOffText: 'controls.closedCaptionsOff' | ||
})((props, context) => { | ||
const [ccOn, setCCOn] = useState(false); | ||
const {textTracks} = props; | ||
const {player} = context; | ||
const activeTextTrack = textTracks.find(textTrack => textTrack.active); | ||
|
||
useEffect(() => { | ||
setCCOn(activeTextTrack?.language !== 'off'); | ||
}, [activeTextTrack]); | ||
|
||
if (!(props.textTracks?.length && props.showCCButton)) { | ||
return undefined; | ||
} | ||
return ( | ||
<ButtonControl name={COMPONENT_NAME}> | ||
{ccOn ? ( | ||
<Tooltip label={props.closedCaptionsOnText}> | ||
<Button | ||
tabIndex="0" | ||
aria-label={props.closedCaptionsOnText} | ||
className={[style.controlButton, style.ccOn].join(' ')} | ||
onClick={() => { | ||
props.notifyClick(true); | ||
player.hideTextTrack(); | ||
}}> | ||
<Icon type={IconType.ClosedCaptionsOn} /> | ||
</Button> | ||
</Tooltip> | ||
) : ( | ||
<Tooltip label={props.closedCaptionsOffText}> | ||
<Button | ||
tabIndex="0" | ||
aria-label={props.closedCaptionsOffText} | ||
className={style.controlButton} | ||
onClick={() => { | ||
props.notifyClick(false); | ||
player.showTextTrack(); | ||
}}> | ||
<Icon type={IconType.ClosedCaptionsOff} /> | ||
</Button> | ||
</Tooltip> | ||
)} | ||
</ButtonControl> | ||
); | ||
}) | ||
) | ||
) | ||
); | ||
|
||
ClosedCaptions.displayName = COMPONENT_NAME; | ||
export {ClosedCaptions}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export {ClosedCaptions} from './closed-captions'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.