Skip to content

Commit

Permalink
Add config "atMostTwoVideos" to track selection
Browse files Browse the repository at this point in the history
Adds a new config option to track selection. It is
true per default and disables the track selection
for events with more than two videos. This is
because standard Opencast workflows are not
equipped to deal with track selection for more
than two videos.
  • Loading branch information
Arnei committed Jun 27, 2024
1 parent 5314aee commit 6700626
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 3 deletions.
10 changes: 8 additions & 2 deletions editor-settings.toml
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,17 @@

# Ensure that at least one video stream remains selected
# Typically, the track selection ensures that at least one video stream
# remains selected. If you would like your users to create selections with
# only audio streams, set this to false.
# remains selected. If you would like your users to be able to create selections
# with only audio streams, set this to false.
# Default: true
#atLeastOneVideo = true

# Disables track selection for events with more than two videos
# If your Opencast can handle track selection for more than two videos, set this
# to false.
# Default: true
#atMostTwoVideos = true

####
# Subtitles
##
Expand Down
1 change: 1 addition & 0 deletions public/editor-settings.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ show = true
[trackSelection]
show = true
atLeastOneVideo = true
atMostTwoVideos = true

[subtitles]
show = true
Expand Down
4 changes: 4 additions & 0 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ interface iSettings {
trackSelection: {
show: boolean,
atLeastOneVideo: boolean,
atMostTwoVideos: boolean,
},
thumbnail: {
show: boolean,
Expand Down Expand Up @@ -95,6 +96,7 @@ const defaultSettings: iSettings = {
trackSelection: {
show: true,
atLeastOneVideo: true,
atMostTwoVideos: true,
},
thumbnail: {
show: false,
Expand Down Expand Up @@ -405,6 +407,8 @@ const SCHEMA = {
},
trackSelection: {
show: types.boolean,
atLeastOneVideo: types.boolean,
atMostTwoVideos: types.boolean,
},
subtitles: {
show: types.boolean,
Expand Down
1 change: 1 addition & 0 deletions src/i18n/locales/en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,7 @@
"title": "Select track(s) for processing",
"help": "At least one track has to be selected.",
"helpAtLeastOneVideo": "At least one video track has to be selected.",
"atMostTwoVideos": "Track Selection is disabled for events with more than two videos",
"customizeLabel": "Customize track selection",
"videoTracksHeader": "Video tracks",
"audioTracksHeader": "Audio tracks",
Expand Down
23 changes: 22 additions & 1 deletion src/main/TrackSelection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import { settings } from "../config";
*/
const TrackSelection: React.FC = () => {
const { t } = useTranslation();
const theme = useTheme();
const dispatch = useAppDispatch();

// Generate list of tracks
Expand Down Expand Up @@ -97,6 +98,13 @@ const TrackSelection: React.FC = () => {
dispatch(setCustomizedTrackSelection(!customizedTrackSelection));
};

const isDisabledBecauseMoreThanTwoVideos = () => {
if (settings.trackSelection.atMostTwoVideos && tracks.length > 2) {
return true;
}
return false;
}

Check warning on line 106 in src/main/TrackSelection.tsx

View workflow job for this annotation

GitHub Actions / test

Missing semicolon

const styles = {
trackSelection: css({
display: "flex",
Expand Down Expand Up @@ -128,7 +136,7 @@ const TrackSelection: React.FC = () => {
transition: "all 0.05s",
width: "100%",
...(
customizedTrackSelection
customizedTrackSelection || isDisabledBecauseMoreThanTwoVideos()
? {}
: {
opacity: "0.7",
Expand All @@ -145,6 +153,19 @@ const TrackSelection: React.FC = () => {
}),
};

if (isDisabledBecauseMoreThanTwoVideos()) {
return (
<div css={styles.trackSelection}>
<Header />
<section css={[styles.selectionSection, styles.leftAlignedSection]}>
<Alert variant="outlined" severity="info" css={css({ color: theme.inverted_text })}>
<span>{t("trackSelection.atMostTwoVideos")}</span>
</Alert>
</section>
</div>
)

Check warning on line 166 in src/main/TrackSelection.tsx

View workflow job for this annotation

GitHub Actions / test

Missing semicolon
}

return (
<div css={styles.trackSelection}>
<Header />
Expand Down

0 comments on commit 6700626

Please sign in to comment.