Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/ar 853 video mute #82

Merged
merged 2 commits into from
Aug 30, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove console.log


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