Skip to content

Commit

Permalink
Add support to play generic iframe video (#862)
Browse files Browse the repository at this point in the history
  • Loading branch information
vtellapmc authored Sep 11, 2024
1 parent 15fd9e6 commit 8d35675
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## Unpublished Changes
* Add support to play generic iframe video

## 1.66.0 09-03-2024
* Update Connatix script tag to use pmcCnx
Expand Down
2 changes: 1 addition & 1 deletion packages/larva-js/build/video-showcase.js

Large diffs are not rendered by default.

17 changes: 16 additions & 1 deletion packages/larva-js/src/interface/VideoShowcase/VideoShowcase.js
Original file line number Diff line number Diff line change
Expand Up @@ -230,9 +230,10 @@ export default class VideoShowcase {
return `https://player.twitch.tv/?video=${ id }`;
}

if ( 'connatix' === type ) {
if ( 'connatix' === type || 'iframe' === type ) {
return id;
}

}

/**
Expand Down Expand Up @@ -283,6 +284,16 @@ export default class VideoShowcase {
);
}

/**
* Remove hidden attribute from the iframe and set the src.
*
* @param {string} IframeUrl - Iframe embed URL from returnUrl.
*/
playIframeUrl( IframeUrl ) {
this.playerUI.iframe.removeAttribute( 'hidden' );
this.playerUI.iframe.setAttribute( 'src', IframeUrl );
}

/**

Check warning on line 297 in packages/larva-js/src/interface/VideoShowcase/VideoShowcase.js

View workflow job for this annotation

GitHub Actions / Test and Lint (18.x)

Expected JSDoc block lines to be aligned
* Remove hidden attribute from jwplayerContainer and play the video with the jwplayer API.
* Note that `playlist` refers to a JWPlayer media object where the videos are handled within
Expand Down Expand Up @@ -366,6 +377,10 @@ export default class VideoShowcase {
const playerId = this.playerUI.player.dataset.videoPlayerId;
this.playConnatix( url, playerId );
}

if ( 'iframe' === state.videoType ) {
this.playIframeUrl( url );
}
}

// Remove any trigger-related data attributes and hide any elements that are not relevant for the player.
Expand Down

0 comments on commit 8d35675

Please sign in to comment.