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

fix(video-player): correct a visual regression with background video in some contexts #12081

Merged
merged 5 commits into from
Oct 23, 2024

Conversation

m4olivei
Copy link
Contributor

@m4olivei m4olivei commented Oct 22, 2024

Related Ticket(s)

Closes # {{Provide issue number link(s) to the related ticket(s) that this pull request addresses}}

Description

Recent changes caused visual regressions due to styles that relied on [background-video="true"]. These updates make background-video a pure boolean attribute and simplify the style selectors accordingly.

Changelog

Changed

  • Make background-video a reflected boolean attribute all the time.
  • Fix a regression with auto-play video.

@m4olivei m4olivei added bug Something isn't working v1 labels Oct 22, 2024
@m4olivei m4olivei requested a review from andy-blum October 22, 2024 21:17
@m4olivei m4olivei requested a review from a team as a code owner October 22, 2024 21:17
@m4olivei m4olivei requested a review from emyarod October 22, 2024 21:17
@m4olivei m4olivei added the test: CDN preview used for generating @carbon/ibmdotcom-web-components CDN for testing label Oct 22, 2024
@m4olivei m4olivei closed this Oct 22, 2024
@m4olivei m4olivei reopened this Oct 22, 2024
@ibmdotcom-bot
Copy link
Contributor

ibmdotcom-bot commented Oct 22, 2024

@ibmdotcom-bot
Copy link
Contributor

ibmdotcom-bot commented Oct 22, 2024

@ibmdotcom-bot
Copy link
Contributor

ibmdotcom-bot commented Oct 22, 2024

@ibmdotcom-bot
Copy link
Contributor

ibmdotcom-bot commented Oct 22, 2024

@ibmdotcom-bot
Copy link
Contributor

ibmdotcom-bot commented Oct 22, 2024

Deploy preview created for package IBM.com Web Components Deploy Preview CDN:
https://ibmdotcom-cdn.s3.us-east.cloud-object-storage.appdomain.cloud/deploy-previews/12081/index.html

Built with commit: 5fc572f5b8c2781e6ff8931ebdd60a8f433a2f44

@andy-blum
Copy link
Member

The leadspace with video isn't playing the video on page load. If I click pause & play again, it will play, but it won't play on load.

https://ibmdotcom-webcomponents.s3.us-east.cloud-object-storage.appdomain.cloud/deploy-previews/12081/iframe.html?args=&id=components-lead-space--super-with-video&viewMode=story

@andy-blum
Copy link
Member

@m4olivei
Copy link
Contributor Author

The leadspace with video isn't playing the video on page load. If I click pause & play again, it will play, but it won't play on load.

https://ibmdotcom-webcomponents.s3.us-east.cloud-object-storage.appdomain.cloud/deploy-previews/12081/iframe.html?args=&id=components-lead-space--super-with-video&viewMode=story

Also seems like inline videos need to be clicked on twice to start the video?

https://ibmdotcom-webcomponents.s3.us-east.cloud-object-storage.appdomain.cloud/deploy-previews/12081/iframe.html?args=&id=components-lead-space-block--with-video&viewMode=story

On my local I needed to go back to the v1.64.0 tag (@carbon/[email protected] ) for this to be working again. Looks like it regressed with #12070

@andy-blum
Copy link
Member

The current video-player suite order of operations

video-player

  • renders thumbnail overlay OR slot, based on several factors
    • Added !this.autoplay in the last PR. This was necessary to cause the iframe to render on load rather than the thumbnail
      return contentState === VIDEO_PLAYER_CONTENT_STATE.THUMBNAIL &&
        !backgroundMode &&
        !this.autoplay
        ? html`
            <div class="${prefix}--video-player__video">
              <button
                class="${prefix}--video-player__image-overlay"
                @click="${this._handleClickOverlay}">
                <dds-image default-src="${thumbnailUrl}" alt="${ifNonNull(name)}">
                  ${PlayVideo({ slot: 'icon' })}
                </dds-image>
              </button>
            </div>
          `
        : html` <slot></slot> `;
  • click button
  • dispatch event
      new CustomEvent(`dds-video-player-content-state-changed`, {
        bubbles: true,
        composed: true,
        detail: {
          videoId,
          contentState: VIDEO_PLAYER_CONTENT_STATE.VIDEO,
          playingMode: this.playingMode,
          name,
          customVideoDescription,
        },
      })

video-player-composite

  • catch event, call this._embedMedia
      protected _handleContentStateChange(event: CustomEvent) {
        const { contentState, playingMode, videoId } = event.detail;
        if (
          contentState === VIDEO_PLAYER_CONTENT_STATE.VIDEO &&
          playingMode === VIDEO_PLAYER_PLAYING_MODE.INLINE &&
          videoId
        ) {
          this._embedMedia?.(videoId, this.backgroundMode);
        }
      }

video-player-contaienr

  • defines _embedMedia
    • calls this._embedVideoImpl

        const embedVideoHandle = await KalturaPlayerAPI.embedMedia(
          videoId,
          playerId,
          this._getPlayerOptions()
        );
    • calls this._getPlayerOptions()

        if (backgroundMode) {
          playerOptions = {
            'topBarContainer.plugin': false,
            'controlBarContainer.plugin': false,
            'largePlayBtn.plugin': false,
            'loadingSpinner.plugin': false,
            'unMuteOverlayButton.plugin': false,
            'EmbedPlayer.DisableVideoTagSupport': false,
            loop: true,
            autoMute: true,
            autoPlay: autoplayPreference,
            // Turn off CTA's including mid-roll card and end cards.
            'ibm.callToActions': false,
            // Turn off captions display, background/ambient videos have no
            // audio.
            closedCaptions: {
              plugin: false,
            },
          };
        } else {
          playerOptions = {
            autoMute: muted,
            // autoPlay: autoplayPreference,
          };
        }

      These override the default flashvars:

        const defaultFlashVars = {
          autoPlay: true,
          closedCaptions: {
            plugin: true,
          },
          titleLabel: {
            plugin: true,
            align: 'left',
            text: '{mediaProxy.entry.name}',
          },
          ibm: {
            template: 'idl',
          },
        };
      • Setting autoPlay: autoplayPreference overrides the default values in the Kaltura API. autoplay there is set to true so that injected iframes play immediately. This has been removed in the latest commit

@andy-blum
Copy link
Member

This does cause an accessibility issue - Since we don't override autoPlay on non-BG videos, it's always true even when prefers-reduced-motion is true. We need to find a way to check autoplayPreference for videos with the auto-play attribute but not for videos that load the thumbnail first as a user has to interact with that video first and we don't want to make them click "play" twice.

@andy-blum
Copy link
Member

Should be fixed now. We need to make sure the below behaviors are all exhibited:

  • Videos that load behind a thumbnail first should play after the overlay is clicked
  • Videos that are background-mode should autoplay, muted, with no Kaltura API
    • autoplay should be overridable by user's OS preference or by pausing a background video in the UI
  • Videos that are autoplay should autoplay on page load
    • autoplay should be overridable by user's OS preference or by pausing a background video in the UI
  • videos that are muted should load as muted (regardless of loading method)

Copy link
Contributor Author

@m4olivei m4olivei left a comment

Choose a reason for hiding this comment

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

Couple things to note. Otherwise, nice work sleuthing the bug. I don't find any issues.

@m4olivei
Copy link
Contributor Author

✅ This is looking good to me now. Testing in Storybook looks good. I've also used the CDN preview together with Requestly to test issues reported with needing two clicks to play at this link as well as background visual regression at this link.

@andy-blum andy-blum added the Ready to merge Label for the pull requests that are ready to merge label Oct 23, 2024
@kodiakhq kodiakhq bot merged commit 863dfdc into carbon-design-system:v1 Oct 23, 2024
21 of 24 checks passed
kodiakhq bot pushed a commit that referenced this pull request Dec 6, 2024
### Related Ticket(s)

[ADCMS-7129](https://jsw.ibm.com/browse/ADCMS-7129)

### Description

Ports a couple of v1 player fixes to v2 that got missed to fix auto-play while maintaining background-video mode:

Work that I've cherry-picked for this PR:
[ADCMS-6363](https://jsw.ibm.com/browse/ADCMS-6363)
#12070 (3d98787)
#12081 (863dfdc)

### Changelog

**New**

- Adds `muted` attribute to `video-player-container`
- Adds storybook examples for `auto-play` and `muted` video player usage

**Changed**

- Fixes `auto-play` attribute on `video-player-container`
- Make `background-video` a reflected boolean attribute all the time.
- Fix a regression with auto-play video.

<!-- React and Web Component deploy previews are enabled by default. -->
<!-- To enable additional available deploy previews, apply the following -->
<!-- labels for the corresponding package: -->
<!-- *** "test: e2e": Codesandbox examples and e2e integration tests -->
<!-- *** "package: services": Services -->
<!-- *** "package: utilities": Utilities -->
<!-- *** "RTL": React / Web Components (RTL) -->
<!-- *** "feature flag": React / Web Components (experimental) -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Ready to merge Label for the pull requests that are ready to merge test: CDN preview used for generating @carbon/ibmdotcom-web-components CDN for testing v1
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants