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

[JS] Add inline YouTube, Vimeo and Dailymotion video playback #7112

Merged
merged 10 commits into from
Mar 24, 2022

Conversation

dclaux
Copy link
Member

@dclaux dclaux commented Mar 11, 2022

Related Issue

Implements #7111

Description

This PR:

  • Updates the behavior of the Media element to use an embedded player (hosted in an iFrame) for YouTube, Vimeo and Daily motion videos
  • Updates the Media element so it attempts to automatically pull a video thumbnail from the appropriate provider to use as a poster, unless the poster property is set
  • Introduces a new public releaseDOMResources API that, when called, discards any expensive DOM resource that might have been instantiated
    • In the current implementation, only the Media element implements this method in a meaningful way, namely by disposing of the iFrame that embeds the inline player. After the iFrame has been disposed of, the Media element reverts to showing the poster.
    • This ability to release resources is very important in Teams where iFrames need to be disposed of when they are scrolled off screen to save memory and processing power.
  • Refactors the Media element source to introduce a new extensibility point, making it possible for host applications to easily add support for additional embedded video players (e.g. Twitch and more)
  • Fixes a problem with adaptivecards-designer-app where the various host app CSS files were no longer copied into the dist folder

Sample Card

{
    "type": "AdaptiveCard",
    "$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
    "version": "1.5",
    "body": [
        {
            "type": "TextBlock",
            "text": "Inline YouTube video player demo",
            "wrap": true,
            "size": "Large",
            "weight": "Bolder"
        },
        {
            "type": "Media",
            "sources": [
                {
                    "url": "https://www.youtube.com/watch?v=YsqcODOEO-M&ab_channel=DavidClaux"
                }
            ]
        }
    ]
}

Replace the url in the above payload with these additional examples to test Vimeo and Dailymotion:

Initial render, with poster pulled from YouTube:
image

After the play button is clicked:
image

How Verified

Verified manually in adaptivecards-designer-app

Microsoft Reviewers: Open in CodeFlow

Add an API to force the release DOM resources
@ghost
Copy link

ghost commented Mar 11, 2022

Hi @dclaux. Thanks for helping make the AdaptiveCards JS renderer + tooling better. As additional verification, once the JS build succeeds, please go to the test site to test out your website/designer changes.

@dclaux dclaux changed the title [JS] Add inline YouTube video playback [JS] Add inline YouTube, Vimeo and Dailymotion video playback Mar 11, 2022
Introduce schema 1.6 and update Media schema
@ghost ghost removed the Needs: Author Feedback label Mar 16, 2022
@dclaux dclaux requested a review from paulcam206 March 16, 2022 01:35
@ghost ghost added the no-recent-activity label Mar 23, 2022
@ghost
Copy link

ghost commented Mar 23, 2022

Hi @dclaux. This pull request has had no recent activity for the past 5 days . Please take the necessary actions (review, address feedback or commit if reviewed already) to move this along.

Copy link
Member

@paulcam206 paulcam206 left a comment

Choose a reason for hiding this comment

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

approved, but there are a couple of small tweaks to the schema text that we should probably take

schemas/src/elements/Media.json Outdated Show resolved Hide resolved
schemas/src/elements/MediaSource.json Outdated Show resolved Hide resolved
Co-authored-by: Paul Campbell <paulcam@microsoft.com>
@ghost ghost removed the no-recent-activity label Mar 23, 2022
@ghost
Copy link

ghost commented Mar 23, 2022

Staleness reset by dclaux

Co-authored-by: Paul Campbell <paulcam@microsoft.com>
@dclaux
Copy link
Member Author

dclaux commented Mar 23, 2022

Thanks @paulcam206. I have made the changes you suggested.

@beervoley beervoley merged commit c3f667f into microsoft:main Mar 24, 2022
michaelfarnsworth pushed a commit to michaelfarnsworth/AdaptiveCards that referenced this pull request Nov 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants