fix(#1701): increase and limitation scrubber

keep-around/fdb88b04b32b9392e76795099e2ec47c9856b38b
Andrei Dekterev 3 years ago
parent 407b5a2041
commit 70cbe4e041
  1. 25
      package-lock.json
  2. 2
      src/features/MatchPage/index.tsx
  3. 38
      src/features/StreamPlayer/components/Chapters/index.tsx
  4. 2
      src/features/StreamPlayer/components/Chapters/styled.tsx
  5. 4
      src/features/StreamPlayer/components/ProgressBar/index.tsx
  6. 40
      src/features/StreamPlayer/components/ProgressBar/styled.tsx
  7. 1
      src/features/StreamPlayer/index.tsx

25
package-lock.json generated

@ -14,7 +14,7 @@
"babel-polyfill": "^6.26.0", "babel-polyfill": "^6.26.0",
"date-fns": "^2.14.0", "date-fns": "^2.14.0",
"history": "^4.10.1", "history": "^4.10.1",
"hls.js": "^0.14.15", "hls.js": "^1.1.1",
"lodash": "^4.17.15", "lodash": "^4.17.15",
"m3u8-parser": "^4.7.0", "m3u8-parser": "^4.7.0",
"oidc-client": "^1.11.5", "oidc-client": "^1.11.5",
@ -46,7 +46,6 @@
"@testing-library/react": "^12.1.2", "@testing-library/react": "^12.1.2",
"@testing-library/user-event": "^7.1.2", "@testing-library/user-event": "^7.1.2",
"@types/history": "^4.7.6", "@types/history": "^4.7.6",
"@types/hls.js": "^0.13.2",
"@types/jest": "^26.0.15", "@types/jest": "^26.0.15",
"@types/lodash": "^4.14.154", "@types/lodash": "^4.14.154",
"@types/node": "^12.0.0", "@types/node": "^12.0.0",
@ -8659,12 +8658,6 @@
"integrity": "sha512-MUc6zSmU3tEVnkQ78q0peeEjKWPUADMlC/t++2bI8WnAG2tvYRPIgHG8lWkXwqc8MsUF6Z2MOf+Mh5sazOmhiQ==", "integrity": "sha512-MUc6zSmU3tEVnkQ78q0peeEjKWPUADMlC/t++2bI8WnAG2tvYRPIgHG8lWkXwqc8MsUF6Z2MOf+Mh5sazOmhiQ==",
"dev": true "dev": true
}, },
"node_modules/@types/hls.js": {
"version": "0.13.3",
"resolved": "https://registry.npmjs.org/@types/hls.js/-/hls.js-0.13.3.tgz",
"integrity": "sha512-Po8ZPCsAcPPuf5OODPEkb6cdWJ/w4BdX1veP7IIOc2WG0x1SW4GEQ1+FHKN1AMG2AePJfNUceJbh5PKtP92yRQ==",
"dev": true
},
"node_modules/@types/hoist-non-react-statics": { "node_modules/@types/hoist-non-react-statics": {
"version": "3.3.1", "version": "3.3.1",
"resolved": "https://registry.npmjs.org/@types/hoist-non-react-statics/-/hoist-non-react-statics-3.3.1.tgz", "resolved": "https://registry.npmjs.org/@types/hoist-non-react-statics/-/hoist-non-react-statics-3.3.1.tgz",
@ -17659,13 +17652,9 @@
} }
}, },
"node_modules/hls.js": { "node_modules/hls.js": {
"version": "0.14.17", "version": "1.2.0",
"resolved": "https://registry.npmjs.org/hls.js/-/hls.js-0.14.17.tgz", "resolved": "https://registry.npmjs.org/hls.js/-/hls.js-1.2.0.tgz",
"integrity": "sha512-25A7+m6qqp6UVkuzUQ//VVh2EEOPYlOBg32ypr34bcPO7liBMOkKFvbjbCBfiPAOTA/7BSx1Dujft3Th57WyFg==", "integrity": "sha512-QIEQIUpBRhcpBMq3NA+/qozG8lbNfVekuX7kCMUlhiVu4382xFWsnwcuBe/CA4Gp/wB/pf2aRBaGRFlxh/FN8g=="
"dependencies": {
"eventemitter3": "^4.0.3",
"url-toolkit": "^2.1.6"
}
}, },
"node_modules/hmac-drbg": { "node_modules/hmac-drbg": {
"version": "1.0.1", "version": "1.0.1",
@ -47026,9 +47015,9 @@
} }
}, },
"hls.js": { "hls.js": {
"version": "1.1.5", "version": "1.2.0",
"resolved": "https://registry.npmjs.org/hls.js/-/hls.js-1.1.5.tgz", "resolved": "https://registry.npmjs.org/hls.js/-/hls.js-1.2.0.tgz",
"integrity": "sha512-mQX5TSNtJEzGo5HPpvcQgCu+BWoKDQM6YYtg/KbgWkmVAcqOCvSTi0SuqG2ZJLXxIzdnFcKU2z7Mrw/YQWhPOA==" "integrity": "sha512-QIEQIUpBRhcpBMq3NA+/qozG8lbNfVekuX7kCMUlhiVu4382xFWsnwcuBe/CA4Gp/wB/pf2aRBaGRFlxh/FN8g=="
}, },
"hmac-drbg": { "hmac-drbg": {
"version": "1.0.1", "version": "1.0.1",

@ -81,8 +81,6 @@ const MatchPageComponent = () => {
<Wrapper> <Wrapper>
{playFromOTT && ( {playFromOTT && (
<LiveMatch <LiveMatch
// events={events}
// profile={profile}
tournamentData={tournamentData} tournamentData={tournamentData}
/> />
)} )}

@ -1,5 +1,3 @@
import { RefObject } from 'react'
import map from 'lodash/map' import map from 'lodash/map'
import type { Chapter } from '../../types' import type { Chapter } from '../../types'
@ -18,25 +16,21 @@ type ChapterWithStyles = Chapter & {
type Props = { type Props = {
chapters: Array<ChapterWithStyles>, chapters: Array<ChapterWithStyles>,
videoRef?: RefObject<HTMLVideoElement>,
} }
export const Chapters = ({ chapters, videoRef }: Props) => { export const Chapters = ({ chapters }: Props) => (
const maxWidthProgressBar = videoRef?.current?.offsetWidth <ChapterList>
return ( {map(chapters, ({
<ChapterList> loaded,
{map(chapters, ({ played,
loaded, width,
played, }, index) => (
width, <ChapterContainer key={index} style={{ width: `${width}%` }}>
}, index) => ( <LoadedProgress style={{ width: `${loaded}%` }} />
<ChapterContainer key={index} style={{ width: `${width}%` }}> <PlayedProgress
<LoadedProgress style={{ width: `${loaded}%` }} /> style={{ width: `${played}%` }}
<PlayedProgress />
style={{ maxWidth: `${maxWidthProgressBar ? `${maxWidthProgressBar - 20}px` : '100%'}`, width: `${played}%` }} </ChapterContainer>
/> ))}
</ChapterContainer> </ChapterList>
))} )
</ChapterList>
)
}

@ -22,6 +22,7 @@ export const LoadedProgress = styled.div`
z-index: 1; z-index: 1;
background-color: rgba(255, 255, 255, 0.6); background-color: rgba(255, 255, 255, 0.6);
height: 100%; height: 100%;
max-width: 100%;
` `
export const PlayedProgress = styled.div` export const PlayedProgress = styled.div`
@ -29,4 +30,5 @@ export const PlayedProgress = styled.div`
z-index: 2; z-index: 2;
background-color: #CC0000; background-color: #CC0000;
height: 100%; height: 100%;
max-width: 100%;
` `

@ -8,7 +8,7 @@ import { useProgressBar } from './hooks'
import { ProgressBarList } from './styled' import { ProgressBarList } from './styled'
export const ProgressBar = (props: Props) => { export const ProgressBar = (props: Props) => {
const { onPlayedProgressChange, videoRef } = props const { onPlayedProgressChange } = props
const progressBarRef = useSlider({ onChange: onPlayedProgressChange }) const progressBarRef = useSlider({ onChange: onPlayedProgressChange })
const { const {
calculatedChapters, calculatedChapters,
@ -18,7 +18,7 @@ export const ProgressBar = (props: Props) => {
return ( return (
<ProgressBarList ref={progressBarRef}> <ProgressBarList ref={progressBarRef}>
<Chapters chapters={calculatedChapters} videoRef={videoRef} /> <Chapters chapters={calculatedChapters} />
<Scrubber style={{ left: `${playedProgressInPercent}%` }}> <Scrubber style={{ left: `${playedProgressInPercent}%` }}>
<TimeTooltip time={time} /> <TimeTooltip time={time} />
</Scrubber> </Scrubber>

@ -1,40 +1,13 @@
import styled, { css } from 'styled-components/macro' import styled, { css } from 'styled-components/macro'
import { isMobileDevice } from 'config/userAgent' import { isMobileDevice } from 'config/userAgent'
import { Wrapper } from '../TimeTooltip/styled' import { Wrapper } from '../TimeTooltip/styled'
export const ProgressBarList = styled.div` export const ProgressBarList = styled.div`
flex-grow: 1; flex-grow: 1;
height: 4px; height: 4px;
position: relative; position: relative;
background-color: rgba(255, 255, 255, 0.3);
cursor: pointer;
${isMobileDevice
? css`
height: 1px;
`
: ''}
`
export const LoadedProgress = styled.div`
position: absolute;
z-index: 1;
background-color: rgba(255, 255, 255, 0.6);
height: 100%;
`
export const PlayedProgress = styled.div`
position: absolute;
z-index: 2;
background-color: #CC0000;
height: 100%;
${isMobileDevice
? css`
background-color: #FFFFFF;
`
: ''}
` `
export const Scrubber = styled.div` export const Scrubber = styled.div`
@ -42,7 +15,7 @@ export const Scrubber = styled.div`
outline: none; outline: none;
position: absolute; position: absolute;
top: 0; top: 0;
transform: translate(-50%, -38%); transform: translate(-50%, -43%);
z-index: 3; z-index: 3;
width: 18px; width: 18px;
height: 18px; height: 18px;
@ -53,12 +26,13 @@ export const Scrubber = styled.div`
:hover ${Wrapper} { :hover ${Wrapper} {
visibility: visible; visibility: visible;
} }
${isMobileDevice ${isMobileDevice
? css` ? css`
width: 14px; width: 30px;
height: 14px; height: 30px;
background-color: #FFFFFF; background-clip: padding-box;
border: 10px solid transparent;
` `
: ''} : ''}
` `

@ -153,7 +153,6 @@ export const StreamPlayer = (props: Props) => {
onPlayedProgressChange={onProgressChange} onPlayedProgressChange={onProgressChange}
playedProgress={playedProgress} playedProgress={playedProgress}
loadedProgress={loadedProgress} loadedProgress={loadedProgress}
videoRef={videoRef}
/> />
</ControlsRow> </ControlsRow>
<ControlsRow> <ControlsRow>

Loading…
Cancel
Save