Skip to content

Commit 44e701e

Browse files
1aurenddananjohnson
authored andcommitted
[B] Ensure video/audio stop playing on dialog close and slide change
1 parent 33162ef commit 44e701e

File tree

7 files changed

+21
-13
lines changed

7 files changed

+21
-13
lines changed

client/src/frontend/components/resource-list/SlideShow/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,7 @@ class ResourceSlideshow extends PureComponent {
196196
resource={slide}
197197
aspectRatio="16 / 9"
198198
loading={!this.isLoaded(index)}
199+
active={index === position - 1}
199200
/>
200201
</Styled.Slide>
201202
));

client/src/frontend/components/resource/media/Factory.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ function ResourceMediaFactory({
99
loading = false,
1010
aspectRatio,
1111
roundedCorners,
12-
enableZoom: enableZoomProp = false
12+
enableZoom: enableZoomProp = false,
13+
active
1314
}) {
1415
if (loading)
1516
return (
@@ -33,7 +34,11 @@ function ResourceMediaFactory({
3334
return (
3435
<Styled.Wrapper $aspectRatio={aspectRatio} $roundedCorners={roundedCorners}>
3536
{enableZoom && <Zoom resource={resource} />}
36-
<KindComponent resource={resource} fixedAspectRatio={!!aspectRatio} />
37+
<KindComponent
38+
resource={resource}
39+
fixedAspectRatio={!!aspectRatio}
40+
active={active}
41+
/>
3742
</Styled.Wrapper>
3843
);
3944
}
@@ -45,7 +50,8 @@ ResourceMediaFactory.propTypes = {
4550
loading: PropTypes.bool,
4651
aspectRatio: PropTypes.string,
4752
roundedCorners: PropTypes.bool,
48-
enableZoom: PropTypes.bool
53+
enableZoom: PropTypes.bool,
54+
active: PropTypes.bool
4955
};
5056

5157
export default ResourceMediaFactory;

client/src/frontend/components/resource/media/kinds/Audio/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ function urlToRelativePath(url) {
1111
return trackUrl.pathname;
1212
}
1313

14-
function ResourcePlayerAudio({ resource }) {
14+
function ResourcePlayerAudio({ resource, active = true }) {
1515
const {
1616
attachmentStyles,
1717
title,
@@ -22,7 +22,7 @@ function ResourcePlayerAudio({ resource }) {
2222

2323
const src = attachmentStyles.original;
2424

25-
if (!src) return null;
25+
if (!src || !active) return null;
2626

2727
const tracks =
2828
resource.relationships?.textTracks

client/src/frontend/components/resource/media/kinds/Video/ExternalVideo/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@ function getSrc(resource) {
2222
}
2323
}
2424

25-
export default function ExternalVideo({ resource }) {
25+
export default function ExternalVideo({ resource, active = true }) {
2626
const src = getSrc(resource);
2727

28-
if (!src) return null;
28+
if (!src || !active) return null;
2929

3030
const { title, externalType } = resource.attributes;
3131

client/src/frontend/components/resource/media/kinds/Video/InternalVideo/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ function urlToRelativePath(url) {
88
return trackUrl.pathname;
99
}
1010

11-
function ResourceMediaVideoInternal({ resource }) {
11+
function ResourceMediaVideoInternal({ resource, active = true }) {
1212
const {
1313
variantPosterStyles,
1414
variantThumbnailStyles,
@@ -19,7 +19,7 @@ function ResourceMediaVideoInternal({ resource }) {
1919

2020
const src = attachmentStyles.original;
2121

22-
if (!src) return null;
22+
if (!src || !active) return null;
2323

2424
const poster =
2525
variantPosterStyles.mediumLandscape ??

client/src/frontend/components/resource/media/kinds/Video/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@ import PropTypes from "prop-types";
22
import ExternalVideo from "./ExternalVideo";
33
import InternalVideo from "./InternalVideo";
44

5-
function ResourceMediaVideo({ resource }) {
5+
function ResourceMediaVideo({ resource, active }) {
66
const VideoComponent =
77
resource.attributes.subKind === "external_video"
88
? ExternalVideo
99
: InternalVideo;
1010

11-
return <VideoComponent resource={resource} />;
11+
return <VideoComponent resource={resource} active={active} />;
1212
}
1313

1414
ResourceMediaVideo.displayName = "Resource.Media.Video";

client/src/reader/components/resource-annotation/Dialog/index.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ export default function ResourceAnnotationDialog({
77
resource,
88
textId,
99
destroyAnnotation,
10+
open,
1011
...dialog
1112
}) {
1213
const resourceEntity = useFromStore({
@@ -30,8 +31,8 @@ export default function ResourceAnnotationDialog({
3031
);
3132

3233
return (
33-
<Dialog title={resourceEntity?.attributes.title} {...dialog}>
34-
{resourceEntity ? renderPreview : null}
34+
<Dialog title={resourceEntity?.attributes.title} open={open} {...dialog}>
35+
{open && renderPreview}
3536
</Dialog>
3637
);
3738
}

0 commit comments

Comments
 (0)