MediaProviders
4 days ago
ProvidersPlaceholder
4 days ago
audioPresets
4 days ago
branding
6 months ago
chapters
2 years ago
components
4 days ago
media
4 days ago
overlays
4 days ago
presets
4 days ago
services
4 years ago
settings
1 month ago
styles
1 year ago
tracks
4 days ago
BlockInspectorControls.js
4 days ago
BlockInspectorControls.scss
4 days ago
Editing.js
1 year ago
LinkPlaceholder.js
1 month ago
Player.js
1 month ago
Preview.js
2 years ago
ProUpgradeModal.js
1 month ago
VisibilityEditor.js
6 months ago
audio-placeholder.js
4 days ago
helpers.js
5 years ago
options.js
4 days ago
placeholder.js
4 days ago
Preview.js
144 lines
| 1 | import { __ } from "@wordpress/i18n"; |
| 2 | import { useState, useEffect } from "@wordpress/element"; |
| 3 | import { Disabled } from "@wordpress/components"; |
| 4 | import { |
| 5 | PrestoCtaOverlayUi, |
| 6 | PrestoEmailOverlayUi, |
| 7 | } from "@presto-player/components-react"; |
| 8 | import { timeToSeconds } from "../util"; |
| 9 | import Player from "./Player"; |
| 10 | |
| 11 | export default ({ |
| 12 | state, |
| 13 | branding, |
| 14 | menu, |
| 15 | src, |
| 16 | poster, |
| 17 | currentTime, |
| 18 | preload, |
| 19 | overlays, |
| 20 | isDisabled = true, |
| 21 | }) => { |
| 22 | const [renderKey, setRenderKey] = useState(1); |
| 23 | const { email_collection, cta, search } = state; |
| 24 | |
| 25 | useEffect(() => { |
| 26 | setRenderKey(renderKey + 1); |
| 27 | }, [ |
| 28 | state.skin, |
| 29 | state["play-large"], |
| 30 | state.rewind, |
| 31 | state.play, |
| 32 | state["fast-forward"], |
| 33 | state.progress, |
| 34 | state["current-time"], |
| 35 | state.mute, |
| 36 | state.volume, |
| 37 | state.speed, |
| 38 | state.pip, |
| 39 | state.fullscreen, |
| 40 | state.captions, |
| 41 | state.hide_logo, |
| 42 | ]); |
| 43 | |
| 44 | const previews = { |
| 45 | email: !!email_collection?.enabled && ( |
| 46 | <PrestoEmailOverlayUi |
| 47 | className="email-overlay" |
| 48 | slot="player-end" |
| 49 | headline={email_collection?.headline} |
| 50 | style={{ |
| 51 | "--presto-player-email-border-radiuss": `${email_collection?.button_radius}px`, |
| 52 | "--plyr-color-main": state?.background_color || branding?.color, |
| 53 | ...(email_collection.button_color |
| 54 | ? { |
| 55 | "--presto-player-button-color": `${email_collection.button_color}`, |
| 56 | } |
| 57 | : {}), |
| 58 | ...(email_collection.button_text_color |
| 59 | ? { |
| 60 | "--presto-player-button-text": `${email_collection.button_text_color}`, |
| 61 | } |
| 62 | : {}), |
| 63 | }} |
| 64 | defaultHeadline={__("Enter your email to play.", "presto-player")} |
| 65 | bottomText={email_collection?.bottom_text} |
| 66 | allowSkip={email_collection?.allow_skip} |
| 67 | skipText={__("Skip", "presto-player")} |
| 68 | buttonText={email_collection?.button_text} |
| 69 | placeholder={__("Email address", "presto-player")} |
| 70 | i18n={window.prestoPlayer.i18n} |
| 71 | /> |
| 72 | ), |
| 73 | cta: !!cta?.enabled && ( |
| 74 | <PrestoCtaOverlayUi |
| 75 | className="cta-overlay" |
| 76 | style={{ |
| 77 | "--presto-player-button-border-radius": `${cta.button_radius}px`, |
| 78 | ...(cta?.background_opacity |
| 79 | ? { |
| 80 | "--presto-player-cta-background-opacity": `${ |
| 81 | cta?.background_opacity / 100 |
| 82 | }`, |
| 83 | } |
| 84 | : {}), |
| 85 | ...(cta.button_color |
| 86 | ? { |
| 87 | "--presto-player-button-color": `${cta.button_color}`, |
| 88 | } |
| 89 | : {}), |
| 90 | ...(cta.button_text_color |
| 91 | ? { |
| 92 | "--presto-player-button-text": `${cta.button_text_color}`, |
| 93 | } |
| 94 | : {}), |
| 95 | }} |
| 96 | slot="player-end" |
| 97 | headline={cta?.headline} |
| 98 | bottom-text={cta?.bottom_text} |
| 99 | button-link={cta?.button_link} |
| 100 | allow-skip={cta?.percentage !== 100 && cta?.show_skip} |
| 101 | borderRadius={cta?.border_radius} |
| 102 | allow-rewatch={cta?.percentage === 100 && cta?.show_rewatch} |
| 103 | skip-text={__("Skip", "presto-player")} |
| 104 | show-button={cta?.show_button} |
| 105 | button-text={cta?.button_text} |
| 106 | i18n={window?.prestoPlayer?.i18n} |
| 107 | /> |
| 108 | ), |
| 109 | }; |
| 110 | |
| 111 | return ( |
| 112 | <Disabled |
| 113 | isDisabled={isDisabled} |
| 114 | className="disable-player" |
| 115 | style={{ width: "100%" }} |
| 116 | > |
| 117 | <div className="presto-player__wrapper"> |
| 118 | <Player |
| 119 | src={src || ""} |
| 120 | className={` |
| 121 | ${menu === "cta" && !!cta?.enabled && "cta-active"} |
| 122 | ${menu === "email" && !!email_collection?.enabled && "email-active"} |
| 123 | ${menu === "search" && !!search?.enabled && "search-active"}`} |
| 124 | preset={state} |
| 125 | branding={{ |
| 126 | ...branding, |
| 127 | logo: state?.hide_logo ? "" : branding["logo"], |
| 128 | }} |
| 129 | i18n={prestoPlayerAdmin?.i18n} |
| 130 | preload={preload} |
| 131 | attributes={{ |
| 132 | chapters: [], |
| 133 | poster: poster, |
| 134 | }} |
| 135 | currentTime={currentTime ? timeToSeconds(currentTime) : ""} |
| 136 | overlays={overlays} |
| 137 | key={renderKey} |
| 138 | adminPreview={previews?.[menu] || ""} |
| 139 | /> |
| 140 | </div> |
| 141 | </Disabled> |
| 142 | ); |
| 143 | }; |
| 144 |