Skip to content

Commit 4409304

Browse files
authored
fix(playback-core): Change default of preferCmcd to 'none' for improved cacheability. Update reference docs to document preferCmcd (et al.). (#1136)
Validation: 1. Load any playback id in https://elements-demo-nextjs-git-fork-cjpillsbury-fix-cmcd-d-3f7695-mux.vercel.app/MuxPlayer 2. Confirm CMCD query params are not added to requests using dev tools. 3. Select "preferCmcd" value of "query" 4. Confirm CDMCD query params are added to requests using dev tools.
1 parent cb7cf3c commit 4409304

File tree

3 files changed

+11
-11
lines changed

3 files changed

+11
-11
lines changed

packages/mux-player-react/REFERENCE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,11 @@
5555
| `playerInitTime` | `number` (timestamp) | Overrides the default [player initialization time](https://docs.mux.com/guides/make-your-data-actionable-with-metadata#optional-configurable-metadata), used by Mux Data for time-based [quality-of-experience (QOE) metrics](https://docs.mux.com/guides/understand-metric-definitions). It will be inferred from instantiation time by default. | Varies |
5656
| `ref` | [React `ref`](https://reactjs.org/docs/refs-and-the-dom.html) | A [React `ref`](https://reactjs.org/docs/refs-and-the-dom.html) to the underlying [`MuxPlayerElement`](../mux-player/REFERENCE.md) web component | `undefined` |
5757
| `proudlyDisplayMuxBadge` | `boolean` | Controls whether to show the Mux badge in the player UI | `false` |
58+
| `preferCmcd` | `"query" \| "header"\| "none"` | Preference for how CMCD data is sent provided in Mux Video requests. Defaults to none for performance reasons. | `"none"` |
5859

5960
<!-- UNDOCUMENTED
6061
// NEW STREAM TYPE VALUES
6162
| `streamType` | `"on-demand" \| "live" \| "unknown"` | The type of stream associated with your Mux Asset. Used along with `targetLiveWindow` to determine what UI/controls to show. | (inferred from `playbackId`, otherwise `"unknown"`) |
62-
| `preferCmcd` | `"query" \| "header"` | Preference for how CMCD data is sent provided in Mux Video requests. Defaults to query params for performance. | `"query"` |
6363
| `playsInline` | `boolean` | Identical to the native `playsInline` property (property equivalent to [`<video playsinline/>` attribute](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/video#attr-playsinline) | `false` |
6464
| `src` | `string` (URL) | Full URL string for the media asset. Typically derived from the `playbackId` | `undefined` |
6565
-->

packages/mux-player/REFERENCE.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,11 @@
5959
| `no-tooltips` | `boolean` | Toggles disabling tooltips in the UI | `false` |
6060
| `player-init-time` | `number` (timestamp) | Overrides the default [player initialization time](https://docs.mux.com/guides/make-your-data-actionable-with-metadata#optional-configurable-metadata), used by Mux Data for time-based [quality-of-experience (QOE) metrics](https://docs.mux.com/guides/understand-metric-definitions). It will be inferred from instantiation time by default. | Varies |
6161
| `proudly-display-mux-badge` | `boolean` | Display the Mux badge in the player UI. | `false` |
62+
| `prefer-cmcd` | `"query" \| "header" \| "none"` | Preference for how CMCD data is sent provided in Mux Video requests. Defaults to none for performance reasons. | `"none"` |
6263

6364
<!-- UNDOCUMENTED
6465
// NEW STREAM TYPE VALUES
6566
| `stream-type` | `"on-demand" \| "live" \| "unknown"` | The type of stream associated with your Mux Asset. Used along with `target-live-window` to determine what UI/controls to show. | (inferred from `playback-id`, otherwise `"unknown"`) |
66-
| `prefer-cmcd` | `"query" \| "header" \| "none"` | Preference for how CMCD data is sent provided in Mux Video requests. Defaults to query params for performance. | `"query"` |
6767
| `playsinline` | `boolean` | Identical to the [`<video playsinline/>` attribute](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/video#attr-playsinline) | `false` |
6868
-->
6969

@@ -163,11 +163,11 @@
163163
| `castReceiver` | `string` (Receiver ID) | The app ID to use for a custom [Google cast receiver](https://developers.google.com/cast/docs/web_receiver/basic). If none is provided, the default receiver app will be used. | `undefined` |
164164
| `castCustomData` | `object` (JSON-serializable) | [Custom Data](https://developers.google.com/cast/docs/reference/web_sender/chrome.cast.media.MediaInfo#customData) to send to your Google cast receiver on initial load. If none is provided, various Mux key/value pairs will be sent. | Mux-specific object |
165165
| `playerInitTime` | `number` (timestamp) | Overrides the default [player initialization time](https://docs.mux.com/guides/make-your-data-actionable-with-metadata#optional-configurable-metadata), used by Mux Data for time-based [quality-of-experience (QOE) metrics](https://docs.mux.com/guides/understand-metric-definitions). It will be inferred from instantiation time by default. | Varies |
166+
| `preferCmcd` | `"query" \| "header" \| "none"` | Preference for how CMCD data is sent provided in Mux Video requests. Defaults to none for performance reasons. | `"none"` |
166167

167168
<!-- UNDOCUMENTED
168169
// NEW STREAM TYPE VALUES
169170
| `streamType` | `"on-demand" \| "live" \| "unknown"` | The type of stream associated with your Mux Asset. Used along with `target-live-window` to determine what UI/controls to show. | (inferred from `playback-id`, otherwise `"unknown"`) |
170-
| `preferCmcd` | `"query" \| "header" \| "none"` | Preference for how CMCD data is sent provided in Mux Video requests. Defaults to query params for performance. | `"query"` |
171171
| `playsInline` | `boolean` | Identical to the native `playsInline` property (property equivalent to [`<video playsinline/>` attribute](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/video#attr-playsinline) | `false` |
172172
| `src` | `string` (URL) | Full URL string for the media asset. Typically derived from the `playbackId` | `undefined` |
173173
| `_hls` <sub><sup>Read only</sup></sub> | [`Hls`](https://github.com/video-dev/hls.js/blob/master/docs/API.md) | Underlying playback engine used by Mux Player. A new instance is created per `playbackId` | `undefined` |

packages/playback-core/src/index.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -612,14 +612,14 @@ export const setupHls = (
612612
const streamTypeConfig = getStreamTypeConfig(streamType);
613613
const drmConfig = getDRMConfig(props);
614614
// NOTE: `metadata.view_session_id` & `metadata.video_id` are guaranteed here (CJP)
615-
const cmcd =
616-
preferCmcd !== CmcdTypes.NONE
617-
? {
618-
useHeaders: preferCmcd === CmcdTypes.HEADER,
619-
sessionId: metadata?.view_session_id,
620-
contentId: metadata?.video_id,
621-
}
622-
: undefined;
615+
// @ts-ignore
616+
const cmcd = [CmcdTypes.QUERY, CmcdTypes.HEADER].includes(preferCmcd)
617+
? {
618+
useHeaders: preferCmcd === CmcdTypes.HEADER,
619+
sessionId: metadata?.view_session_id,
620+
contentId: metadata?.video_id,
621+
}
622+
: undefined;
623623
const hls = new Hls({
624624
// Kind of like preload metadata, but causes spinner.
625625
// autoStartLoad: false,

0 commit comments

Comments
 (0)