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

feat: add quality selector #734

Merged
merged 5 commits into from
Aug 11, 2023
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
3 changes: 3 additions & 0 deletions examples/nextjs-with-typescript/pages/MuxPlayer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,9 @@ const ControlCustomizationCSSVars = [
"--bottom-mute-button",
"--volume-range",
"--bottom-volume-range",
"--rendition-selectmenu",
"--top-rendition-selectmenu",
"--bottom-rendition-selectmenu",
"--playback-rate-button",
"--bottom-playback-rate-button",
"--captions-button",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ <h1><a href="/">Elements</a></h1>
<mux-player
id="muxPlayer"
stream-type="on-demand"
playback-id="23s11nz72DsoN657h4314PjKKjsF2JG33eBQQt6B95I"
playback-id="VcmKA6aqzIzlg3MayLJDnbF55kX00mds028Z65QxvBYaA"
luwes marked this conversation as resolved.
Show resolved Hide resolved
></mux-player>

<br>
Expand Down
2 changes: 1 addition & 1 deletion packages/mux-player/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@
"dependencies": {
"@mux/mux-video": "0.15.6",
"@mux/playback-core": "0.18.5",
"media-chrome": "^1.2.2"
"media-chrome": "^1.2.3"
},
"devDependencies": {
"@mux/esbuilder": "0.1.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/mux-player/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { globalThis, document } from './polyfills';
import { MediaController } from 'media-chrome';
import 'media-chrome/dist/experimental/media-captions-selectmenu.js';
import 'media-chrome/dist/experimental/index.js';
Copy link
Contributor

Choose a reason for hiding this comment

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

nitpick(blocking): We should directly import each experimental feature we use so we aren't unnecessarily adding to our bundles and are being explicit about the dependencies we are using.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I had it first like that but then I thought what about custom themes.
it's nice to have all the experimental elements to drop in without needing imports.
the 1 left is playback-rate-selectmenu and dependencies, comparative to the Mux player bundle it's a drop in a bucket. thoughts?

Copy link
Contributor

Choose a reason for hiding this comment

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

hmmm... I'm sold as solution for now. Maybe next week in media chrome office hours we can try to come up with a solution to make sure themes can include any of their dependencies? This has come up in the past and would hopefully avoid your concern here.

import { MediaThemeElement } from 'media-chrome/dist/media-theme-element.js';
import MuxVideoElement, { MediaError, Attributes as MuxVideoAttributes } from '@mux/mux-video';
import {
Expand Down
4 changes: 4 additions & 0 deletions packages/mux-player/src/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
--media-mute-button-display: var(--mute-button);
--media-captions-button-display: var(--captions-button);
--media-captions-selectmenu-display: var(--captions-selectmenu, var(--media-captions-button-display));
--media-rendition-selectmenu-display: var(--rendition-selectmenu);
--media-airplay-button-display: var(--airplay-button);
--media-pip-button-display: var(--pip-button);
--media-fullscreen-button-display: var(--fullscreen-button);
Expand Down Expand Up @@ -54,6 +55,7 @@ media-theme {
--captions-selectmenu,
var(--media-captions-button-display, var(--top-captions-selectmenu))
);
--media-rendition-selectmenu-display: var(--rendition-selectmenu, var(--top-rendition-selectmenu));
--media-airplay-button-display: var(--airplay-button, var(--top-airplay-button));
--media-pip-button-display: var(--pip-button, var(--top-pip-button));
--media-fullscreen-button-display: var(--fullscreen-button, var(--top-fullscreen-button));
Expand All @@ -79,6 +81,7 @@ media-theme {
--captions-selectmenu,
var(--media-captions-button-display, var(--center-captions-selectmenu))
);
--media-rendition-selectmenu-display: var(--rendition-selectmenu, var(--center-rendition-selectmenu));
--media-airplay-button-display: var(--airplay-button, var(--center-airplay-button));
--media-pip-button-display: var(--pip-button, var(--center-pip-button));
--media-fullscreen-button-display: var(--fullscreen-button, var(--center-fullscreen-button));
Expand All @@ -103,6 +106,7 @@ media-theme {
--captions-selectmenu,
var(--media-captions-button-display, var(--bottom-captions-selectmenu))
);
--media-rendition-selectmenu-display: var(--rendition-selectmenu, var(--bottom-rendition-selectmenu));
--media-airplay-button-display: var(--airplay-button, var(--bottom-airplay-button));
--media-pip-button-display: var(--pip-button, var(--bottom-pip-button));
--media-fullscreen-button-display: var(--fullscreen-button, var(--bottom-fullscreen-button));
Expand Down
137 changes: 71 additions & 66 deletions packages/mux-player/src/themes/classic/classic.html

Large diffs are not rendered by default.

9 changes: 1 addition & 8 deletions packages/mux-player/test/player.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,14 +77,7 @@ describe('<mux-player>', () => {

await aTimeout(1000);

assert.isAtLeast(Math.round(player.currentTime), 0, 'is about 1s in, at least 0s in');
assert.isAtMost(Math.round(player.currentTime), 1, 'is about 1s in, at most 1s in');

player.playbackRate = 2;
await aTimeout(1000);

assert.isAtLeast(Math.round(player.currentTime), 2, 'is about 3s in, at least 2s in');
assert.isAtMost(Math.round(player.currentTime), 3, 'is about 3s in, at most 3s in');
assert.isAtLeast(Math.round(player.currentTime), 1, 'is greater or equal to 1s');
});

(isSafari ? it.skip : it)('playbackId is forwarded to the media element', async function () {
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -10605,10 +10605,10 @@ [email protected]:
resolved "https://registry.yarnpkg.com/mdn-data/-/mdn-data-2.0.4.tgz#699b3c38ac6f1d728091a64650b65d388502fd5b"
integrity sha512-iV3XNKw06j5Q7mi6h+9vbx23Tv7JkjEVgKHW4pimwyDGWm0OIQntJJ+u1C6mg6mK1EaTv42XQ7w76yuzH7M2cA==

media-chrome@^1.2.2:
version "1.2.2"
resolved "https://registry.yarnpkg.com/media-chrome/-/media-chrome-1.2.2.tgz#5b8ceea4648b3b219eed0218af47d7fda5836b06"
integrity sha512-sJGuYwFc923Jxd57b2RGGcBaE03/hL7wOo3JveBWETb+6KY9NKJwrZDKw2RszT/GNsME1jy4N+h69wNfqXkHfA==
media-chrome@^1.2.3:
version "1.2.3"
resolved "https://registry.yarnpkg.com/media-chrome/-/media-chrome-1.2.3.tgz#ebab267a2615b4973cfe03856be3d5a20bac30e3"
integrity sha512-Burup/EaHMVnlNKUXgf7YdJSvTh+LV0hDTBwQrwsyJlUj3d58f4PMgRsyJe4k0nI7Ka5ThYo8uU6ipZ/AQIY3w==

[email protected], media-tracks@>=0.2.1:
version "0.2.1"
Expand Down
Loading