Skip to content

Commit

Permalink
Merge pull request #82 from os2display/feature/AR-853-video-mute
Browse files Browse the repository at this point in the history
Feature/ar 853 video mute
  • Loading branch information
sinejespersen authored Aug 30, 2022
2 parents 4533758 + dd4c073 commit ffb546a
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 2 deletions.
8 changes: 8 additions & 0 deletions build/video-admin.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,13 @@
"acceptedMimetypes": ["video/webm", "video/mp4"],
"formGroupClasses": "h5 mb-3",
"helpText": "Følgende formatter accepteres: .webm, mp4"
},
{
"key": "video-form-sound",
"input": "checkbox",
"label": "Afspil lyd",
"name": "sound",
"formGroupClasses": "col-md-9 mt-3",
"helpText": "Hvis videoen har lyd, skal enheden konfigureres til at automatisk afspilning er muligt."
}
]
2 changes: 1 addition & 1 deletion build/video.js

Large diffs are not rendered by default.

8 changes: 8 additions & 0 deletions src/video/video-admin.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,13 @@
"acceptedMimetypes": ["video/webm", "video/mp4"],
"formGroupClasses": "h5 mb-3",
"helpText": "Følgende formatter accepteres: .webm, mp4"
},
{
"key": "video-form-sound",
"input": "checkbox",
"label": "Afspil lyd",
"name": "sound",
"formGroupClasses": "col-md-9 mt-3",
"helpText": "Hvis videoen har lyd, skal enheden konfigureres til at automatisk afspilning er muligt."
}
]
9 changes: 8 additions & 1 deletion src/video/video.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import "../global-styles.css";
function Video({ slide, content, run, slideDone, executionId }) {
const videoUrls = getAllMediaUrlsFromField(slide.mediaData, content.video);
const videoRef = useRef();
const { sound } = content;

const onEnded = () => {
slideDone(slide);
Expand All @@ -31,6 +32,11 @@ function Video({ slide, content, run, slideDone, executionId }) {
videoRef?.current?.load();
videoRef?.current?.addEventListener("ended", onEnded);
videoRef?.current?.addEventListener("error", onError);
videoRef.current.muted = true;
if (sound) {
videoRef.current.muted = false;
}
console.log(videoRef.current.muted);

const promise = videoRef.current.play();

Expand All @@ -56,7 +62,7 @@ function Video({ slide, content, run, slideDone, executionId }) {
{/* eslint-disable-next-line jsx-a11y/media-has-caption */}
<video width="100%" height="100%" ref={videoRef}>
{videoUrls.map((url) => (
<source key={url} src={url} />
<source muted={!sound} key={url} src={url} />
))}
</video>

Expand All @@ -76,6 +82,7 @@ Video.propTypes = {
}),
}).isRequired,
content: PropTypes.shape({
sound: PropTypes.bool,
video: PropTypes.arrayOf(PropTypes.string),
}).isRequired,
executionId: PropTypes.string.isRequired,
Expand Down

0 comments on commit ffb546a

Please sign in to comment.