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

Add withCredentials option to MediaPlayer component #576

Merged
merged 1 commit into from
Jul 18, 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
13 changes: 10 additions & 3 deletions dist/ramp.cjs.js
Original file line number Diff line number Diff line change
Expand Up @@ -7208,7 +7208,9 @@ var MediaPlayer = function MediaPlayer(_ref) {
_ref$enablePlaybackRa = _ref.enablePlaybackRate,
enablePlaybackRate = _ref$enablePlaybackRa === void 0 ? false : _ref$enablePlaybackRa,
_ref$enableTitleLink = _ref.enableTitleLink,
enableTitleLink = _ref$enableTitleLink === void 0 ? false : _ref$enableTitleLink;
enableTitleLink = _ref$enableTitleLink === void 0 ? false : _ref$enableTitleLink,
_ref$withCredentials = _ref.withCredentials,
withCredentials = _ref$withCredentials === void 0 ? false : _ref$withCredentials;
var manifestState = useManifestState();
var playerState = usePlayerState();
var playerDispatch = usePlayerDispatch();
Expand Down Expand Up @@ -7545,6 +7547,11 @@ var MediaPlayer = function MediaPlayer(_ref) {
}
};
React__default["default"].useEffect(function () {
var hlsOptions = withCredentials ? {
hls: {
withCredentials: true
}
} : {};
var videoJsOptions;
// Only build the full set of option for the first playable Canvas since
// these options are only used on the initia Video.js instance creation
Expand Down Expand Up @@ -7590,9 +7597,9 @@ var MediaPlayer = function MediaPlayer(_ref) {
},
sources: isMultiSourced ? [playerConfig.sources[srcIndex]] : playerConfig.sources,
// Enable native text track functionality in iPhones and iPads
html5: {
html5: _objectSpread$3(_objectSpread$3({}, hlsOptions), {}, {
nativeTextTracks: IS_MOBILE && !IS_ANDROID
},
}),
/*
Setting this option helps to override VideoJS's default 'keydown' event handler, whenever
the focus is on a native VideoJS control icon (e.g. play toggle).
Expand Down
2 changes: 1 addition & 1 deletion dist/ramp.cjs.min.js

Large diffs are not rendered by default.

13 changes: 10 additions & 3 deletions dist/ramp.esm.js
Original file line number Diff line number Diff line change
Expand Up @@ -7176,7 +7176,9 @@ var MediaPlayer = function MediaPlayer(_ref) {
_ref$enablePlaybackRa = _ref.enablePlaybackRate,
enablePlaybackRate = _ref$enablePlaybackRa === void 0 ? false : _ref$enablePlaybackRa,
_ref$enableTitleLink = _ref.enableTitleLink,
enableTitleLink = _ref$enableTitleLink === void 0 ? false : _ref$enableTitleLink;
enableTitleLink = _ref$enableTitleLink === void 0 ? false : _ref$enableTitleLink,
_ref$withCredentials = _ref.withCredentials,
withCredentials = _ref$withCredentials === void 0 ? false : _ref$withCredentials;
var manifestState = useManifestState();
var playerState = usePlayerState();
var playerDispatch = usePlayerDispatch();
Expand Down Expand Up @@ -7513,6 +7515,11 @@ var MediaPlayer = function MediaPlayer(_ref) {
}
};
React.useEffect(function () {
var hlsOptions = withCredentials ? {
hls: {
withCredentials: true
}
} : {};
var videoJsOptions;
// Only build the full set of option for the first playable Canvas since
// these options are only used on the initia Video.js instance creation
Expand Down Expand Up @@ -7558,9 +7565,9 @@ var MediaPlayer = function MediaPlayer(_ref) {
},
sources: isMultiSourced ? [playerConfig.sources[srcIndex]] : playerConfig.sources,
// Enable native text track functionality in iPhones and iPads
html5: {
html5: _objectSpread$3(_objectSpread$3({}, hlsOptions), {}, {
nativeTextTracks: IS_MOBILE && !IS_ANDROID
},
}),
/*
Setting this option helps to override VideoJS's default 'keydown' event handler, whenever
the focus is on a native VideoJS control icon (e.g. play toggle).
Expand Down
13 changes: 10 additions & 3 deletions dist/ramp.umd.js
Original file line number Diff line number Diff line change
Expand Up @@ -7182,7 +7182,9 @@
_ref$enablePlaybackRa = _ref.enablePlaybackRate,
enablePlaybackRate = _ref$enablePlaybackRa === void 0 ? false : _ref$enablePlaybackRa,
_ref$enableTitleLink = _ref.enableTitleLink,
enableTitleLink = _ref$enableTitleLink === void 0 ? false : _ref$enableTitleLink;
enableTitleLink = _ref$enableTitleLink === void 0 ? false : _ref$enableTitleLink,
_ref$withCredentials = _ref.withCredentials,
withCredentials = _ref$withCredentials === void 0 ? false : _ref$withCredentials;
var manifestState = useManifestState();
var playerState = usePlayerState();
var playerDispatch = usePlayerDispatch();
Expand Down Expand Up @@ -7519,6 +7521,11 @@
}
};
React__default["default"].useEffect(function () {
var hlsOptions = withCredentials ? {
hls: {
withCredentials: true
}
} : {};
var videoJsOptions;
// Only build the full set of option for the first playable Canvas since
// these options are only used on the initia Video.js instance creation
Expand Down Expand Up @@ -7564,9 +7571,9 @@
},
sources: isMultiSourced ? [playerConfig.sources[srcIndex]] : playerConfig.sources,
// Enable native text track functionality in iPhones and iPads
html5: {
html5: _objectSpread$3(_objectSpread$3({}, hlsOptions), {}, {
nativeTextTracks: IS_MOBILE && !IS_ANDROID
},
}),
/*
Setting this option helps to override VideoJS's default 'keydown' event handler, whenever
the focus is on a native VideoJS control icon (e.g. play toggle).
Expand Down
2 changes: 2 additions & 0 deletions docs/build/bundle.5c105872.js

Large diffs are not rendered by default.

2 changes: 0 additions & 2 deletions docs/build/bundle.a4618b4d.js

This file was deleted.

2 changes: 1 addition & 1 deletion docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@
</head>
<body>
<div id="rsg-root"></div>
<script src="build/bundle.a4618b4d.js"></script>
<script src="build/bundle.5c105872.js"></script>
</body>
</html>
3 changes: 3 additions & 0 deletions src/components/MediaPlayer/MediaPlayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ const MediaPlayer = ({
enablePIP = false,
enablePlaybackRate = false,
enableTitleLink = false,
withCredentials = false,
}) => {
const manifestState = useManifestState();
const playerState = usePlayerState();
Expand Down Expand Up @@ -314,6 +315,7 @@ const MediaPlayer = ({
};

React.useEffect(() => {
const hlsOptions = withCredentials ? { hls: { withCredentials: true } } : {}
let videoJsOptions;
// Only build the full set of option for the first playable Canvas since
// these options are only used on the initia Video.js instance creation
Expand Down Expand Up @@ -371,6 +373,7 @@ const MediaPlayer = ({
: playerConfig.sources,
// Enable native text track functionality in iPhones and iPads
html5: {
...hlsOptions,
nativeTextTracks: IS_MOBILE && !IS_ANDROID
},
/*
Expand Down
1 change: 1 addition & 0 deletions src/components/MediaPlayer/MediaPlayer.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ MediaPlayer component provides a player that facilitates both audio and video me
- `enablePIP` : accepts a Boolean value, which has a default value of `false` and is _not required_. When this is set to `true`, it adds an icon to the player's control bar to enable Picture-In-Picture feature for the current player. This icon is a VideoJS component.
- `enablePlaybackRate`: accepts a Boolean value, which has a default value of `false` and is _not required_. When this is set to `true`, it adds an icon to the player's control bar which provides a menu to select a different playback speed for the media. The available speed options are 0.5x, 0.75x, 1x, 1.5x, and 2x. This icon is a VideoJS component.
- `enableTitleLink`: accepts a Boolean value, which has a default value of `false` and is _not required_. When this is set to `true`, it adds a title bar to the video player which displays `Manifest Label - Active Canvas Label` with an href attribute linking to the URL in the active canvas's `id`. This is a custom VideoJS component added to the VideoJS instance in Ramp.
- `withCredentials`: accepts a Boolean value, which has a default value of `false` and is _not required_. Once this is set to `true` it causes the VideoJS component to include any available `Authentication` and `Cookie` headers with [XHR requests](https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/withCredentials). There are special server-side CORS requirements that go along with this option – specifically, the streaming server should include an appropriate [`Access-Control-Allow-Credentials`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Access-Control-Allow-Credentials) header, and a non-wildcard [`Access-Control-Allow-Origin`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Access-Control-Allow-Origin) specifying the server originating the request.

To import and use this component from the library;
```js static
Expand Down