Skip to content

Commit

Permalink
[BUGFIX] trial video and cover video
Browse files Browse the repository at this point in the history
  • Loading branch information
kkshyu committed Oct 15, 2021
1 parent 3c048c4 commit 49760ae
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 28 deletions.
28 changes: 14 additions & 14 deletions src/components/blog/PostCover.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ import { Button, Icon as AntdIcon } from 'antd'
import { useApp } from 'lodestar-app-element/src/contexts/AppContext'
import React, { useCallback, useEffect, useRef, useState } from 'react'
import { defineMessages, useIntl } from 'react-intl'
import ReactPlayer from 'react-player'
import styled, { css } from 'styled-components'
import { desktopViewMixin } from '../../helpers'
import { ReactComponent as ArrowUpCircleIcon } from '../../images/arrow-up-circle.svg'
import EmptyCover from '../../images/empty-cover.png'
import { ReactComponent as ShopOIcon } from '../../images/shop-o.svg'
import { MerchandiseProps } from '../../types/merchandise'
import { StyledPlayer } from '../program/ProgramBanner'
import MerchandiseModal from './MerchandiseModal'

const messages = defineMessages({
Expand Down Expand Up @@ -169,19 +169,19 @@ const PostCover: React.VFC<{
<Icon as={ArrowUpCircleIcon} className="cursor-pointer" onClick={() => backToTop()} />
<AntdIcon type="close" className="cursor-pointer" onClick={() => setIsClosed(true)} />
</StyledHeader>
<StyledVideoWrapper>
<ReactPlayer
url={coverUrl || undefined}
width="100%"
height="100%"
style={{
position: 'absolute',
top: '0',
left: '0',
}}
controls
/>
</StyledVideoWrapper>
{coverUrl && (
<StyledVideoWrapper>
<StyledPlayer>
<video
className="smartvideo"
src={coverUrl}
controls
autoPlay
style={{ width: '100%', height: '100%' }}
/>
</StyledPlayer>
</StyledVideoWrapper>
)}
</StyledVideoBlock>
</div>

Expand Down
2 changes: 1 addition & 1 deletion src/components/common/VideoPlayer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const VideoPlayer: React.VFC<{ videoId: string; animated?: boolean } & Partial<S
error: Error | null
}>()
useEffect(() => {
if (!initialized && authToken && videoId) {
if (!initialized && videoId) {
setInitialized(true)
axios
.post(
Expand Down
12 changes: 10 additions & 2 deletions src/components/program/ProgramBanner/PerpetualProgramBanner.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react'
import { Link } from 'react-router-dom'
import styled from 'styled-components'
import { StyledReactPlayer, StyledTags, StyledTitle, StyledVideoWrapper } from '.'
import { StyledPlayer, StyledTags, StyledTitle, StyledVideoWrapper } from '.'
import { ProgramProps } from '../../../types/program'
import BlurredBanner from '../../common/BlurredBanner'
import { BREAK_POINT } from '../../common/Responsive'
Expand Down Expand Up @@ -47,7 +47,15 @@ const PerpetualProgramBanner: React.VFC<{
<StyledVideoBlock>
<div className="container">
<StyledVideoWrapper>
<StyledReactPlayer controls url={program.coverVideoUrl} width="100%" height="100%" />
<StyledPlayer>
<video
className="smartvideo"
src={program.coverVideoUrl}
controls
autoPlay
style={{ width: '100%', height: '100%' }}
/>
</StyledPlayer>
</StyledVideoWrapper>
</div>
</StyledVideoBlock>
Expand Down
12 changes: 10 additions & 2 deletions src/components/program/ProgramBanner/SubscriptionProgramBanner.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from 'react'
import { useIntl } from 'react-intl'
import { Link } from 'react-router-dom'
import styled from 'styled-components'
import { StyledReactPlayer, StyledTags, StyledTitle, StyledVideoWrapper } from '.'
import { StyledPlayer, StyledTags, StyledTitle, StyledVideoWrapper } from '.'
import { productMessages } from '../../../helpers/translation'
import { ProgramProps, ProgramRoleProps } from '../../../types/program'
import MemberAvatar from '../../common/MemberAvatar'
Expand Down Expand Up @@ -64,7 +64,15 @@ const SubscriptionProgramBanner: React.VFC<{
<StyledMediaBlock>
<StyledVideoWrapper backgroundImage={program.coverUrl || ''}>
{program.coverVideoUrl && (
<StyledReactPlayer controls url={program.coverVideoUrl} width="100%" height="100%" />
<StyledPlayer>
<video
className="smartvideo"
src={program.coverVideoUrl}
controls
autoPlay
style={{ width: '100%', height: '100%' }}
/>
</StyledPlayer>
)}
</StyledVideoWrapper>
</StyledMediaBlock>
Expand Down
3 changes: 1 addition & 2 deletions src/components/program/ProgramBanner/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import ReactPlayer from 'react-player'
import styled from 'styled-components'
import { BREAK_POINT } from '../../common/Responsive'

Expand All @@ -25,7 +24,7 @@ export const StyledVideoWrapper = styled.div<{ backgroundImage?: string }>`
background-size: cover;
background-position: center;
`
export const StyledReactPlayer = styled(ReactPlayer)`
export const StyledPlayer = styled.div`
position: absolute;
top: 0;
right: 0;
Expand Down
11 changes: 4 additions & 7 deletions src/components/project/FundingCoverBlock.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react'
import ReactPlayer from 'react-player'
import styled from 'styled-components'
import { StyledPlayer } from '../program/ProgramBanner'

const StyledWrapper = styled.div<{ coverType: string; coverUrl: string }>`
position: relative;
Expand All @@ -18,12 +18,9 @@ const FundingCoverBlock: React.VFC<{
return (
<StyledWrapper coverType={coverType} coverUrl={coverUrl}>
{coverType === 'video' && (
<ReactPlayer
url={coverUrl}
width="100%"
height="100%"
style={{ position: 'absolute', top: 0, right: 0, bottom: 0, left: 0 }}
/>
<StyledPlayer>
<video className="smartvideo" src={coverUrl} controls autoPlay style={{ width: '100%', height: '100%' }} />
</StyledPlayer>
)}
</StyledWrapper>
)
Expand Down

0 comments on commit 49760ae

Please sign in to comment.