From 3e5564717cf0c932c9c34b8b117bc0db0e5b28e7 Mon Sep 17 00:00:00 2001 From: Alexander Zinchuk Date: Fri, 23 Jul 2021 17:01:41 +0300 Subject: [PATCH] Viewer Player: Display big play button on iOS (#1309) --- src/components/mediaViewer/VideoPlayer.scss | 19 +++++++++++++++++++ src/components/mediaViewer/VideoPlayer.tsx | 13 ++++++++++++- 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/src/components/mediaViewer/VideoPlayer.scss b/src/components/mediaViewer/VideoPlayer.scss index 44edf2fb..45bdbf81 100644 --- a/src/components/mediaViewer/VideoPlayer.scss +++ b/src/components/mediaViewer/VideoPlayer.scss @@ -57,6 +57,25 @@ } } + .play-button { + position: absolute; + left: 50%; + top: 50%; + transform: translate(-50%, -50%); + width: 3.25rem; + height: 3.25rem; + background-color: rgba(0, 0, 0, 0.5) !important; + body:not(.animation-level-0) & { + transition: opacity .3s ease !important; + } + + .icon-play { + font-size: 1.75rem; + position: relative; + left: .125rem; + } + } + .spinner-container { position: absolute; top: 0; diff --git a/src/components/mediaViewer/VideoPlayer.tsx b/src/components/mediaViewer/VideoPlayer.tsx index ed10c881..9ead5304 100644 --- a/src/components/mediaViewer/VideoPlayer.tsx +++ b/src/components/mediaViewer/VideoPlayer.tsx @@ -2,6 +2,8 @@ import React, { FC, memo, useCallback, useEffect, useRef, useState, } from '../../lib/teact/teact'; +import { ApiDimensions } from '../../api/types'; + import { IS_IOS, IS_SINGLE_COLUMN_LAYOUT, IS_TOUCH_ENV } from '../../util/environment'; import useShowTransition from '../../hooks/useShowTransition'; import useBuffering from '../../hooks/useBuffering'; @@ -11,9 +13,9 @@ import safePlay from '../../util/safePlay'; import VideoPlayerControls from './VideoPlayerControls'; import ProgressSpinner from '../ui/ProgressSpinner'; +import Button from '../ui/Button'; import './VideoPlayer.scss'; -import { ApiDimensions } from '../../api/types'; type OwnProps = { url?: string; @@ -53,6 +55,10 @@ const VideoPlayer: FC = ({ shouldRender: shouldRenderSpinner, transitionClassNames: spinnerClassNames, } = useShowTransition(!isBuffered, undefined, undefined, 'slow'); + const { + shouldRender: shouldRenderPlayButton, + transitionClassNames: playButtonClassNames, + } = useShowTransition(IS_IOS && !isPlayed && !shouldRenderSpinner, undefined, undefined, 'slow'); useEffect(() => { if (noPlay || !isMediaViewerOpen) { @@ -173,6 +179,11 @@ const VideoPlayer: FC = ({ {url && } + {shouldRenderPlayButton && ( + + )} {shouldRenderSpinner && (
{!isBuffered &&
Buffering...
}