Skip to content

Commit

Permalink
feat: add crossOrigin prop to allow users to configure for cross-orig…
Browse files Browse the repository at this point in the history
…in subtitle resources
  • Loading branch information
will0684 committed Jun 6, 2023
1 parent ff9411e commit 5c8a1bc
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
18 changes: 16 additions & 2 deletions src/components/Media/VideoPlayer/Video.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import { Image } from "../../Image/Image";
import "../styles.css";

export function Video(props) {
const { id, videoURL, poster, description, trackProps } = props;
const { id, videoURL, poster, description, trackProps, crossOrigin } = props;
const [state, setState] = React.useState({
pausePlay: false,
mute: false,
Expand Down Expand Up @@ -180,7 +180,12 @@ export function Video(props) {
onEnded={handleEnd}
config={{
file: {
attributes: { poster: poster, crossOrigin: "anonymous" },
attributes: {
poster: poster,
crossOrigin: `${
crossOrigin === true ? "anonymous" : false
}`,
},
tracks: [
{
kind: trackProps.kind,
Expand Down Expand Up @@ -435,6 +440,10 @@ export function Video(props) {
);
}

Video.defaultProps = {
crossOrigin: false,
};

Video.propTypes = {
/**
* component id
Expand Down Expand Up @@ -468,4 +477,9 @@ Video.propTypes = {
srcLang: PropTypes.oneOf(["en", "fr"]),
kind: PropTypes.string,
}),

/**
* Allow cross-origin requests for subtitle/caption tracks (false by default)
*/
crossOrigin: PropTypes.bool,
};
1 change: 1 addition & 0 deletions src/components/Media/VideoPlayer/Video.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,5 @@ VideoPlayer.args = {
src: exampleCaps,
srcLang: "en",
},
crossOrigin: false,
};

0 comments on commit 5c8a1bc

Please sign in to comment.