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

demo: change removed property limitVideoWidth to videoResolutionLimit #1345

Merged
merged 1 commit into from
Jan 3, 2024
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
56 changes: 36 additions & 20 deletions demo/full/scripts/components/Options/VideoAdaptiveSettings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,20 @@ const { Fragment } = React;
function VideoAdaptiveSettings({
defaultVideoRepresentationsSwitchingMode,
onDefaultVideoRepresentationsSwitchingModeChange,
limitVideoWidth,
videoResolutionLimit,
throttleVideoBitrateWhenHidden,
onLimitVideoWidthChange,
onVideoResolutionLimitChange,
onThrottleVideoBitrateWhenHiddenChange,
}: {
defaultVideoRepresentationsSwitchingMode: IVideoRepresentationsSwitchingMode;
onDefaultVideoRepresentationsSwitchingModeChange: (
mode: IVideoRepresentationsSwitchingMode
) => void;
limitVideoWidth: boolean;
videoResolutionLimit: "videoElement" | "screen" | "none";
throttleVideoBitrateWhenHidden: boolean;
onLimitVideoWidthChange: (newVal: boolean) => void;
onVideoResolutionLimitChange: (
newVal: { index: number, value: string}
) => void;
onThrottleVideoBitrateWhenHiddenChange: (newVal: boolean) => void;
}): JSX.Element {
let defaultVideoRepresentationsSwitchingModeDescMsg;
Expand All @@ -52,6 +54,19 @@ function VideoAdaptiveSettings({
break;
}

let videoResolutionLimitDescMsg;
switch (videoResolutionLimit) {
case "none":
videoResolutionLimitDescMsg = "No limit on the video Representation’s resolution will be automatically applied.";
break;
case "screen":
videoResolutionLimitDescMsg = "The loaded video Representation will be throttled according to the screen’s dimensions.";
break;
case "videoElement":
videoResolutionLimitDescMsg = "The loaded video Representation will be throttled according to the given videoElement’s dimensions.";
break;
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe we should have a column limit to the demo.
We have one for the source but it does not seem to be enabled for the demo code.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Apparently there is one but with the options"ignoreStrings": true that ignores lines that contains a string
I'm ok to remove this, but it should be done in a separate PR as there will be probably a lot of changes when correcting all warnings

Copy link
Collaborator

Choose a reason for hiding this comment

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

OK I agree


const onSwitchModeChange = React.useCallback(
({ value }: { value: string }) => {
onDefaultVideoRepresentationsSwitchingModeChange(
Expand Down Expand Up @@ -82,22 +97,23 @@ function VideoAdaptiveSettings({
</span>
</li>
<li>
<div>
<Checkbox
className="playerOptionsCheckBox playerOptionsCheckBoxTitle"
name="limitVideoWidth"
ariaLabel="Limit video width option"
checked={limitVideoWidth}
onChange={onLimitVideoWidthChange}
>
Limit Video Width
</Checkbox>
<span className="option-desc">
{limitVideoWidth ?
"Limiting video width to the current <video> element's width" :
"Not limiting video width to the current <video> element's width"}
</span>
</div>
<Select
ariaLabel="Select the videoResolutionLimit"
className="playerOptionInput"
disabled={false}
name="videoResolutionLimit"
onChange={onVideoResolutionLimitChange}
selected={{
value: "none",
index: undefined,
}}
options={["videoElement", "screen", "none"]}
>
Limit Video Resolution
</Select>
<span className="option-desc">
{videoResolutionLimitDescMsg}
</span>
</li>
<li>
<div className="playerOptionInput">
Expand Down
28 changes: 17 additions & 11 deletions demo/full/scripts/controllers/Settings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ function Settings({
showOptions: boolean;
}): JSX.Element | null {
const {
limitVideoWidth,
videoResolutionLimit,
maxBufferAhead,
maxBufferBehind,
maxVideoBufferSize,
Expand Down Expand Up @@ -84,14 +84,20 @@ function Settings({
});
}, [updateLoadVideoOptions]);

const onLimitVideoWidthChange = useCallback((limitVideoWidth: boolean) => {
updatePlayerOptions((prevOptions) => {
if (limitVideoWidth === prevOptions.limitVideoWidth) {
return prevOptions;
}
return Object.assign({}, prevOptions, { limitVideoWidth });
});
}, [updatePlayerOptions]);
const onVideoResolutionLimitChange = useCallback(
(videoResolutionLimitArg: { value: string}) => {
updatePlayerOptions((prevOptions) => {
if (videoResolutionLimitArg.value ===
prevOptions.videoResolutionLimit) {
return prevOptions;
}
return Object.assign(
{},
prevOptions,
{ videoResolutionLimit: videoResolutionLimitArg.value }
);
});
}, [updatePlayerOptions]);

const onThrottleVideoBitrateWhenHiddenChange = useCallback((
value: boolean
Expand Down Expand Up @@ -285,12 +291,12 @@ function Settings({
defaultVideoRepresentationsSwitchingMode={
defaultVideoRepresentationsSwitchingMode
}
limitVideoWidth={limitVideoWidth}
videoResolutionLimit={videoResolutionLimit}
throttleVideoBitrateWhenHidden={throttleVideoBitrateWhenHidden}
onDefaultVideoRepresentationsSwitchingModeChange={
onDefaultVideoRepresentationsSwitchingModeChange
}
onLimitVideoWidthChange={onLimitVideoWidthChange}
onVideoResolutionLimitChange={onVideoResolutionLimitChange}
onThrottleVideoBitrateWhenHiddenChange={
onThrottleVideoBitrateWhenHiddenChange
}
Expand Down
7 changes: 5 additions & 2 deletions demo/full/scripts/lib/defaultOptionsValues.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
import type { IConstructorOptions, ILoadVideoOptions } from "../../../../src/public_types";

const defaultOptionsValues = {
player: {
limitVideoWidth: false,
videoResolutionLimit: "none",
maxBufferAhead: Infinity,
maxBufferBehind: Infinity,
maxVideoBufferSize: Infinity,
throttleVideoBitrateWhenHidden: false,
wantedBufferAhead: 30,
},
loadVideo: {
transport: "dash",
autoPlay: true,
defaultAudioTrackSwitchingMode: "reload",
enableFastSwitching: true,
Expand All @@ -23,7 +26,7 @@ const defaultOptionsValues = {
},
onCodecSwitch: "continue",
},
};
} satisfies { player: IConstructorOptions, loadVideo: ILoadVideoOptions };
Copy link
Collaborator

Choose a reason for hiding this comment

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

👍


export type IConstructorSettings = typeof defaultOptionsValues.player;
export type ILoadVideoSettings = typeof defaultOptionsValues.loadVideo;
Expand Down
Loading