diff --git a/__tests__/src/components/AudioViewer.test.js b/__tests__/src/components/AudioViewer.test.js index be26d1a6565bd371a1c6a62e2ca9eb919eaa0736..ecaf18ac54b2a14111538d65f182606780f04600 100644 --- a/__tests__/src/components/AudioViewer.test.js +++ b/__tests__/src/components/AudioViewer.test.js @@ -23,8 +23,8 @@ describe('AudioViewer', () => { { getFormat: () => 'video/mp4', id: 2 }, ], }, true); - expect(wrapper.contains(<source src="1" type="video/mp4" />)); - expect(wrapper.contains(<source src="2" type="video/mp4" />)); + expect(wrapper.contains(<source src={1} type="video/mp4" />)).toBe(true); + expect(wrapper.contains(<source src={2} type="video/mp4" />)).toBe(true); }); it('passes through configurable options', () => { wrapper = createWrapper({ @@ -44,8 +44,8 @@ describe('AudioViewer', () => { { getLabel: () => 'French', getProperty: () => 'fr', id: 2 }, ], }, true); - expect(wrapper.contains(<track src="1" label="English" srcLang="en" />)); - expect(wrapper.contains(<track src="2" label="French" srcLang="fr" />)); + expect(wrapper.contains(<track src={1} label="English" srcLang="en" />)).toBe(true); + expect(wrapper.contains(<track src={2} label="French" srcLang="fr" />)).toBe(true); }); }); }); diff --git a/__tests__/src/components/VideoViewer.test.js b/__tests__/src/components/VideoViewer.test.js index b261e8cb87ea2d65f90ae163bbbd22a3077fe2d5..99e229393b995bcfb68359fc684ab4b1412cf515 100644 --- a/__tests__/src/components/VideoViewer.test.js +++ b/__tests__/src/components/VideoViewer.test.js @@ -23,8 +23,8 @@ describe('VideoViewer', () => { { getFormat: () => 'video/mp4', id: 2 }, ], }, true); - expect(wrapper.contains(<source src="1" type="video/mp4" />)); - expect(wrapper.contains(<source src="2" type="video/mp4" />)); + expect(wrapper.contains(<source src={1} type="video/mp4" />)).toBe(true); + expect(wrapper.contains(<source src={2} type="video/mp4" />)).toBe(true); }); it('passes through configurable options', () => { wrapper = createWrapper({ @@ -44,8 +44,8 @@ describe('VideoViewer', () => { { getFormat: () => 'video/mp4', id: 1 }, ], }, true); - expect(wrapper.contains(<track src="1" label="English" srcLang="en" />)); - expect(wrapper.contains(<track src="2" label="French" srcLang="fr" />)); + expect(wrapper.contains(<track src={1} label="English" srcLang="en" />)).toBe(true); + expect(wrapper.contains(<track src={2} label="French" srcLang="fr" />)).toBe(true); }); }); }); diff --git a/src/components/AudioViewer.js b/src/components/AudioViewer.js index c802f8319ba23458ec07e12c7f445a28e845607b..5d80e059cf8ddb6fba46fbc70a9dbb966ab8388f 100644 --- a/src/components/AudioViewer.js +++ b/src/components/AudioViewer.js @@ -6,7 +6,9 @@ export class AudioViewer extends Component { /* eslint-disable jsx-a11y/media-has-caption */ /** */ render() { - const { classes, audioOptions, audioResources } = this.props; + const { + captions, classes, audioOptions, audioResources, + } = this.props; return ( <div className={classes.container}> @@ -16,6 +18,11 @@ export class AudioViewer extends Component { <source src={audio.id} type={audio.getFormat()} /> </Fragment> ))} + {captions.map(caption => ( + <Fragment key={caption.id}> + <track src={caption.id} label={caption.getLabel()} srcLang={caption.getProperty('language')} /> + </Fragment> + ))} </audio> </div> ); @@ -26,10 +33,12 @@ export class AudioViewer extends Component { AudioViewer.propTypes = { audioOptions: PropTypes.object, // eslint-disable-line react/forbid-prop-types audioResources: PropTypes.arrayOf(PropTypes.object), + captions: PropTypes.arrayOf(PropTypes.object), classes: PropTypes.objectOf(PropTypes.string).isRequired, }; AudioViewer.defaultProps = { audioOptions: {}, audioResources: [], + captions: [], }; diff --git a/src/containers/AudioViewer.js b/src/containers/AudioViewer.js index 34c88f623d9e1bf23b30ae6b137fc442852767be..e422c6d6b6e00458773de3c365080307590b9fd9 100644 --- a/src/containers/AudioViewer.js +++ b/src/containers/AudioViewer.js @@ -4,13 +4,14 @@ import { withTranslation } from 'react-i18next'; import { withStyles } from '@material-ui/core'; import { withPlugins } from '../extend/withPlugins'; import { AudioViewer } from '../components/AudioViewer'; -import { getConfig, getVisibleCanvasAudioResources } from '../state/selectors'; +import { getConfig, getVisibleCanvasAudioResources, getVisibleCanvasCaptions } from '../state/selectors'; /** */ const mapStateToProps = (state, { windowId }) => ( { audioOptions: getConfig(state).audioOptions, audioResources: getVisibleCanvasAudioResources(state, { windowId }) || [], + captions: getVisibleCanvasCaptions(state, { windowId }) || [], } );