From ac2e0a55a0bae3a471f6004438803697d782b7bd Mon Sep 17 00:00:00 2001 From: Mirlan Date: Wed, 16 Dec 2020 18:22:10 +0600 Subject: [PATCH] Ott 667 player autoplay fix (#251) * fix(667): removed stream request timeout * fix(667): filter out unknown video qualities --- src/features/StreamPlayer/hooks/useVideoQuality.tsx | 13 ++++++++++++- src/requests/getLiveVideos.tsx | 1 - 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/features/StreamPlayer/hooks/useVideoQuality.tsx b/src/features/StreamPlayer/hooks/useVideoQuality.tsx index caa91ad9..27878d5f 100644 --- a/src/features/StreamPlayer/hooks/useVideoQuality.tsx +++ b/src/features/StreamPlayer/hooks/useVideoQuality.tsx @@ -12,6 +12,7 @@ import uniqBy from 'lodash/uniqBy' import isEmpty from 'lodash/isEmpty' import orderBy from 'lodash/orderBy' import isString from 'lodash/isString' +import filter from 'lodash/fp/filter' import { useLocalStore } from 'hooks' @@ -20,10 +21,20 @@ const autoQuality = { level: -1, } +/** + * Убирает из списка качества без height + * + * Когда в манифесте нет данных о качествах стрима hls.levels содержит + * непонятное качество без свойств height, width и тд для определения + * какое это качество + */ +const filterOutUnknownQualities = filter(({ height }: Hls.Level) => Boolean(height)) + const getVideoQualities = (levels: Array) => { if (isEmpty(levels)) return [] - const qualities = map(levels, (level, i) => ({ + const filteredQualities = filterOutUnknownQualities(levels) + const qualities = map(filteredQualities, (level, i) => ({ label: String(level.height), level: i, })) diff --git a/src/requests/getLiveVideos.tsx b/src/requests/getLiveVideos.tsx index 5d391fc5..1e3da644 100644 --- a/src/requests/getLiveVideos.tsx +++ b/src/requests/getLiveVideos.tsx @@ -18,7 +18,6 @@ export const getLiveVideos = ( return callApi({ config, - timeout: 2000, url: `${API_ROOT}/video/stream`, }).then((videos: LiveVideos) => { if (isEmpty(videos)) return Promise.reject()