[Video] Lexicon implementation (#4881)
* implement AppBskyEmbedVideo lexicon in player * add alt to native player * add prerelease package * update prerelease * add video embed view manually from record * fix type error on example video * black bg + use aspect ratio on web * add video to feeds * fix video overflowing aspect ratio * remove prerelease package --------- Co-authored-by: Samuel Newman <10959775+mozzius@users.noreply.github.com>zio/stable
parent
b136c44287
commit
d92731b1eb
|
@ -52,7 +52,7 @@
|
||||||
"open-analyzer": "EXPO_PUBLIC_OPEN_ANALYZER=1 yarn build-web"
|
"open-analyzer": "EXPO_PUBLIC_OPEN_ANALYZER=1 yarn build-web"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@atproto/api": "0.13.3",
|
"@atproto/api": "0.13.5",
|
||||||
"@bam.tech/react-native-image-resizer": "^3.0.4",
|
"@bam.tech/react-native-image-resizer": "^3.0.4",
|
||||||
"@braintree/sanitize-url": "^6.0.2",
|
"@braintree/sanitize-url": "^6.0.2",
|
||||||
"@discord/bottom-sheet": "bluesky-social/react-native-bottom-sheet",
|
"@discord/bottom-sheet": "bluesky-social/react-native-bottom-sheet",
|
||||||
|
|
|
@ -428,6 +428,7 @@ export function PostThread({uri}: {uri: string | undefined}) {
|
||||||
(item.ctx.depth < 0 && !!item.parent) || item.ctx.depth > 1
|
(item.ctx.depth < 0 && !!item.parent) || item.ctx.depth > 1
|
||||||
const hasUnrevealedParents =
|
const hasUnrevealedParents =
|
||||||
index === 0 && skeleton?.parents && maxParents < skeleton.parents.length
|
index === 0 && skeleton?.parents && maxParents < skeleton.parents.length
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<View
|
<View
|
||||||
ref={item.ctx.isHighlightedPost ? highlightedPostRef : undefined}
|
ref={item.ctx.isHighlightedPost ? highlightedPostRef : undefined}
|
||||||
|
|
|
@ -17,37 +17,37 @@ import {msg, Trans} from '@lingui/macro'
|
||||||
import {useLingui} from '@lingui/react'
|
import {useLingui} from '@lingui/react'
|
||||||
import {useQueryClient} from '@tanstack/react-query'
|
import {useQueryClient} from '@tanstack/react-query'
|
||||||
|
|
||||||
|
import {isReasonFeedSource, ReasonFeedSource} from '#/lib/api/feed/types'
|
||||||
|
import {MAX_POST_LINES} from '#/lib/constants'
|
||||||
|
import {usePalette} from '#/lib/hooks/usePalette'
|
||||||
|
import {makeProfileLink} from '#/lib/routes/links'
|
||||||
import {useGate} from '#/lib/statsig/statsig'
|
import {useGate} from '#/lib/statsig/statsig'
|
||||||
|
import {sanitizeDisplayName} from '#/lib/strings/display-names'
|
||||||
|
import {sanitizeHandle} from '#/lib/strings/handles'
|
||||||
|
import {countLines} from '#/lib/strings/helpers'
|
||||||
|
import {s} from '#/lib/styles'
|
||||||
import {POST_TOMBSTONE, Shadow, usePostShadow} from '#/state/cache/post-shadow'
|
import {POST_TOMBSTONE, Shadow, usePostShadow} from '#/state/cache/post-shadow'
|
||||||
import {useFeedFeedbackContext} from '#/state/feed-feedback'
|
import {useFeedFeedbackContext} from '#/state/feed-feedback'
|
||||||
|
import {precacheProfile} from '#/state/queries/profile'
|
||||||
import {useSession} from '#/state/session'
|
import {useSession} from '#/state/session'
|
||||||
import {useComposerControls} from '#/state/shell/composer'
|
import {useComposerControls} from '#/state/shell/composer'
|
||||||
import {useMergedThreadgateHiddenReplies} from '#/state/threadgate-hidden-replies'
|
import {useMergedThreadgateHiddenReplies} from '#/state/threadgate-hidden-replies'
|
||||||
import {isReasonFeedSource, ReasonFeedSource} from 'lib/api/feed/types'
|
import {FeedNameText} from '#/view/com/util/FeedInfoText'
|
||||||
import {MAX_POST_LINES} from 'lib/constants'
|
import {PostCtrls} from '#/view/com/util/post-ctrls/PostCtrls'
|
||||||
import {usePalette} from 'lib/hooks/usePalette'
|
import {PostEmbeds} from '#/view/com/util/post-embeds'
|
||||||
import {makeProfileLink} from 'lib/routes/links'
|
import {PostMeta} from '#/view/com/util/PostMeta'
|
||||||
import {sanitizeDisplayName} from 'lib/strings/display-names'
|
import {Text} from '#/view/com/util/text/Text'
|
||||||
import {sanitizeHandle} from 'lib/strings/handles'
|
import {PreviewableUserAvatar} from '#/view/com/util/UserAvatar'
|
||||||
import {countLines} from 'lib/strings/helpers'
|
|
||||||
import {s} from 'lib/styles'
|
|
||||||
import {precacheProfile} from 'state/queries/profile'
|
|
||||||
import {atoms as a} from '#/alf'
|
import {atoms as a} from '#/alf'
|
||||||
import {Repost_Stroke2_Corner2_Rounded as Repost} from '#/components/icons/Repost'
|
import {Repost_Stroke2_Corner2_Rounded as Repost} from '#/components/icons/Repost'
|
||||||
import {ContentHider} from '#/components/moderation/ContentHider'
|
import {ContentHider} from '#/components/moderation/ContentHider'
|
||||||
|
import {LabelsOnMyPost} from '#/components/moderation/LabelsOnMe'
|
||||||
|
import {PostAlerts} from '#/components/moderation/PostAlerts'
|
||||||
import {AppModerationCause} from '#/components/Pills'
|
import {AppModerationCause} from '#/components/Pills'
|
||||||
import {ProfileHoverCard} from '#/components/ProfileHoverCard'
|
import {ProfileHoverCard} from '#/components/ProfileHoverCard'
|
||||||
import {RichText} from '#/components/RichText'
|
import {RichText} from '#/components/RichText'
|
||||||
import {LabelsOnMyPost} from '../../../components/moderation/LabelsOnMe'
|
|
||||||
import {PostAlerts} from '../../../components/moderation/PostAlerts'
|
|
||||||
import {FeedNameText} from '../util/FeedInfoText'
|
|
||||||
import {Link, TextLink, TextLinkOnWebOnly} from '../util/Link'
|
import {Link, TextLink, TextLinkOnWebOnly} from '../util/Link'
|
||||||
import {PostCtrls} from '../util/post-ctrls/PostCtrls'
|
|
||||||
import {PostEmbeds} from '../util/post-embeds'
|
|
||||||
import {VideoEmbed} from '../util/post-embeds/VideoEmbed'
|
import {VideoEmbed} from '../util/post-embeds/VideoEmbed'
|
||||||
import {PostMeta} from '../util/PostMeta'
|
|
||||||
import {Text} from '../util/text/Text'
|
|
||||||
import {PreviewableUserAvatar} from '../util/UserAvatar'
|
|
||||||
import {AviFollowButton} from './AviFollowButton'
|
import {AviFollowButton} from './AviFollowButton'
|
||||||
|
|
||||||
interface FeedItemProps {
|
interface FeedItemProps {
|
||||||
|
@ -571,7 +571,11 @@ function VideoDebug() {
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<VideoEmbed
|
<VideoEmbed
|
||||||
source={`https://lumi.jazco.dev/watch/did:plc:q6gjnaw2blty4crticxkmujt/Qmc8w93UpTa2adJHg4ZhnDPrBs1EsbzrekzPcqF5SwusuZ/playlist.m3u8?ignore_me_just_testing_frontend_stuff=${id}`}
|
embed={{
|
||||||
|
playlist: `https://lumi.jazco.dev/watch/did:plc:q6gjnaw2blty4crticxkmujt/Qmc8w93UpTa2adJHg4ZhnDPrBs1EsbzrekzPcqF5SwusuZ/playlist.m3u8?ignore_me_just_testing_frontend_stuff=${id}`,
|
||||||
|
cid: 'Qmc8w93UpTa2adJHg4ZhnDPrBs1EsbzrekzPcqF5SwusuZ',
|
||||||
|
aspectRatio: {height: 9, width: 16},
|
||||||
|
}}
|
||||||
/>
|
/>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,21 +1,25 @@
|
||||||
import React, {useCallback, useState} from 'react'
|
import React, {useCallback, useState} from 'react'
|
||||||
import {View} from 'react-native'
|
import {View} from 'react-native'
|
||||||
|
import {Image} from 'expo-image'
|
||||||
|
import {AppBskyEmbedVideo} from '@atproto/api'
|
||||||
import {msg, Trans} from '@lingui/macro'
|
import {msg, Trans} from '@lingui/macro'
|
||||||
import {useLingui} from '@lingui/react'
|
import {useLingui} from '@lingui/react'
|
||||||
|
|
||||||
import {VideoEmbedInnerNative} from 'view/com/util/post-embeds/VideoEmbedInner/VideoEmbedInnerNative'
|
import {clamp} from '#/lib/numbers'
|
||||||
|
import {useGate} from '#/lib/statsig/statsig'
|
||||||
|
import {VideoEmbedInnerNative} from '#/view/com/util/post-embeds/VideoEmbedInner/VideoEmbedInnerNative'
|
||||||
import {atoms as a, useTheme} from '#/alf'
|
import {atoms as a, useTheme} from '#/alf'
|
||||||
import {Button, ButtonIcon} from '#/components/Button'
|
import {Button} from '#/components/Button'
|
||||||
import {Play_Filled_Corner2_Rounded as PlayIcon} from '#/components/icons/Play'
|
import {Play_Filled_Corner2_Rounded as PlayIcon} from '#/components/icons/Play'
|
||||||
import {VisibilityView} from '../../../../../modules/expo-bluesky-swiss-army'
|
import {VisibilityView} from '../../../../../modules/expo-bluesky-swiss-army'
|
||||||
import {ErrorBoundary} from '../ErrorBoundary'
|
import {ErrorBoundary} from '../ErrorBoundary'
|
||||||
import {useActiveVideoNative} from './ActiveVideoNativeContext'
|
import {useActiveVideoNative} from './ActiveVideoNativeContext'
|
||||||
import * as VideoFallback from './VideoEmbedInner/VideoFallback'
|
import * as VideoFallback from './VideoEmbedInner/VideoFallback'
|
||||||
|
|
||||||
export function VideoEmbed({source}: {source: string}) {
|
export function VideoEmbed({embed}: {embed: AppBskyEmbedVideo.View}) {
|
||||||
const t = useTheme()
|
const t = useTheme()
|
||||||
const {activeSource, setActiveSource} = useActiveVideoNative()
|
const {activeSource, setActiveSource} = useActiveVideoNative()
|
||||||
const isActive = source === activeSource
|
const isActive = embed.playlist === activeSource
|
||||||
const {_} = useLingui()
|
const {_} = useLingui()
|
||||||
|
|
||||||
const [key, setKey] = useState(0)
|
const [key, setKey] = useState(0)
|
||||||
|
@ -25,39 +29,61 @@ export function VideoEmbed({source}: {source: string}) {
|
||||||
),
|
),
|
||||||
[key],
|
[key],
|
||||||
)
|
)
|
||||||
|
const gate = useGate()
|
||||||
|
|
||||||
|
if (!gate('videos')) {
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
|
||||||
|
let aspectRatio = 16 / 9
|
||||||
|
|
||||||
|
if (embed.aspectRatio) {
|
||||||
|
const {width, height} = embed.aspectRatio
|
||||||
|
aspectRatio = width / height
|
||||||
|
aspectRatio = clamp(aspectRatio, 1 / 1, 3 / 1)
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<View
|
<View
|
||||||
style={[
|
style={[
|
||||||
a.w_full,
|
a.w_full,
|
||||||
a.rounded_sm,
|
a.rounded_sm,
|
||||||
{aspectRatio: 16 / 9},
|
|
||||||
a.overflow_hidden,
|
a.overflow_hidden,
|
||||||
t.atoms.bg_contrast_25,
|
{aspectRatio},
|
||||||
|
{backgroundColor: t.palette.black},
|
||||||
a.my_xs,
|
a.my_xs,
|
||||||
]}>
|
]}>
|
||||||
<ErrorBoundary renderError={renderError} key={key}>
|
<ErrorBoundary renderError={renderError} key={key}>
|
||||||
<VisibilityView
|
<VisibilityView
|
||||||
enabled={true}
|
enabled={true}
|
||||||
onChangeStatus={isActive => {
|
onChangeStatus={isVisible => {
|
||||||
if (isActive) {
|
if (isVisible) {
|
||||||
setActiveSource(source)
|
setActiveSource(embed.playlist)
|
||||||
}
|
}
|
||||||
}}>
|
}}>
|
||||||
{isActive ? (
|
{isActive ? (
|
||||||
<VideoEmbedInnerNative />
|
<VideoEmbedInnerNative embed={embed} />
|
||||||
) : (
|
) : (
|
||||||
<Button
|
<>
|
||||||
style={[a.flex_1, t.atoms.bg_contrast_25]}
|
<Image
|
||||||
onPress={() => {
|
source={{uri: embed.thumbnail}}
|
||||||
setActiveSource(source)
|
alt={embed.alt}
|
||||||
}}
|
style={a.flex_1}
|
||||||
label={_(msg`Play video`)}
|
contentFit="contain"
|
||||||
variant="ghost"
|
accessibilityIgnoresInvertColors
|
||||||
color="secondary"
|
/>
|
||||||
size="large">
|
<Button
|
||||||
<ButtonIcon icon={PlayIcon} />
|
style={[a.absolute, a.inset_0]}
|
||||||
</Button>
|
onPress={() => {
|
||||||
|
setActiveSource(embed.playlist)
|
||||||
|
}}
|
||||||
|
label={_(msg`Play video`)}
|
||||||
|
variant="ghost"
|
||||||
|
color="secondary"
|
||||||
|
size="large">
|
||||||
|
<PlayIcon width={48} fill={t.palette.white} />
|
||||||
|
</Button>
|
||||||
|
</>
|
||||||
)}
|
)}
|
||||||
</VisibilityView>
|
</VisibilityView>
|
||||||
</ErrorBoundary>
|
</ErrorBoundary>
|
||||||
|
|
|
@ -1,19 +1,23 @@
|
||||||
import React, {useCallback, useEffect, useRef, useState} from 'react'
|
import React, {useCallback, useEffect, useRef, useState} from 'react'
|
||||||
import {View} from 'react-native'
|
import {View} from 'react-native'
|
||||||
|
import {AppBskyEmbedVideo} from '@atproto/api'
|
||||||
import {Trans} from '@lingui/macro'
|
import {Trans} from '@lingui/macro'
|
||||||
|
|
||||||
|
import {clamp} from '#/lib/numbers'
|
||||||
|
import {useGate} from '#/lib/statsig/statsig'
|
||||||
import {
|
import {
|
||||||
HLSUnsupportedError,
|
HLSUnsupportedError,
|
||||||
VideoEmbedInnerWeb,
|
VideoEmbedInnerWeb,
|
||||||
} from 'view/com/util/post-embeds/VideoEmbedInner/VideoEmbedInnerWeb'
|
} from '#/view/com/util/post-embeds/VideoEmbedInner/VideoEmbedInnerWeb'
|
||||||
import {atoms as a, useTheme} from '#/alf'
|
import {atoms as a, useTheme} from '#/alf'
|
||||||
import {ErrorBoundary} from '../ErrorBoundary'
|
import {ErrorBoundary} from '../ErrorBoundary'
|
||||||
import {useActiveVideoWeb} from './ActiveVideoWebContext'
|
import {useActiveVideoWeb} from './ActiveVideoWebContext'
|
||||||
import * as VideoFallback from './VideoEmbedInner/VideoFallback'
|
import * as VideoFallback from './VideoEmbedInner/VideoFallback'
|
||||||
|
|
||||||
export function VideoEmbed({source}: {source: string}) {
|
export function VideoEmbed({embed}: {embed: AppBskyEmbedVideo.View}) {
|
||||||
const t = useTheme()
|
const t = useTheme()
|
||||||
const ref = useRef<HTMLDivElement>(null)
|
const ref = useRef<HTMLDivElement>(null)
|
||||||
|
const gate = useGate()
|
||||||
const {active, setActive, sendPosition, currentActiveView} =
|
const {active, setActive, sendPosition, currentActiveView} =
|
||||||
useActiveVideoWeb()
|
useActiveVideoWeb()
|
||||||
const [onScreen, setOnScreen] = useState(false)
|
const [onScreen, setOnScreen] = useState(false)
|
||||||
|
@ -43,12 +47,25 @@ export function VideoEmbed({source}: {source: string}) {
|
||||||
[key],
|
[key],
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if (!gate('videos')) {
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
|
||||||
|
let aspectRatio = 16 / 9
|
||||||
|
|
||||||
|
if (embed.aspectRatio) {
|
||||||
|
const {width, height} = embed.aspectRatio
|
||||||
|
// min: 3/1, max: square
|
||||||
|
aspectRatio = clamp(width / height, 1 / 1, 3 / 1)
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<View
|
<View
|
||||||
style={[
|
style={[
|
||||||
a.w_full,
|
a.w_full,
|
||||||
{aspectRatio: 16 / 9},
|
{aspectRatio},
|
||||||
t.atoms.bg_contrast_25,
|
{backgroundColor: t.palette.black},
|
||||||
|
a.relative,
|
||||||
a.rounded_sm,
|
a.rounded_sm,
|
||||||
a.my_xs,
|
a.my_xs,
|
||||||
]}>
|
]}>
|
||||||
|
@ -61,7 +78,7 @@ export function VideoEmbed({source}: {source: string}) {
|
||||||
sendPosition={sendPosition}
|
sendPosition={sendPosition}
|
||||||
isAnyViewActive={currentActiveView !== null}>
|
isAnyViewActive={currentActiveView !== null}>
|
||||||
<VideoEmbedInnerWeb
|
<VideoEmbedInnerWeb
|
||||||
source={source}
|
embed={embed}
|
||||||
active={active}
|
active={active}
|
||||||
setActive={setActive}
|
setActive={setActive}
|
||||||
onScreen={onScreen}
|
onScreen={onScreen}
|
||||||
|
|
|
@ -2,12 +2,14 @@ import React, {useCallback, useEffect, useRef, useState} from 'react'
|
||||||
import {Pressable, View} from 'react-native'
|
import {Pressable, View} from 'react-native'
|
||||||
import Animated, {FadeInDown} from 'react-native-reanimated'
|
import Animated, {FadeInDown} from 'react-native-reanimated'
|
||||||
import {VideoPlayer, VideoView} from 'expo-video'
|
import {VideoPlayer, VideoView} from 'expo-video'
|
||||||
|
import {AppBskyEmbedVideo} from '@atproto/api'
|
||||||
import {msg} from '@lingui/macro'
|
import {msg} from '@lingui/macro'
|
||||||
import {useLingui} from '@lingui/react'
|
import {useLingui} from '@lingui/react'
|
||||||
import {useIsFocused} from '@react-navigation/native'
|
import {useIsFocused} from '@react-navigation/native'
|
||||||
|
|
||||||
import {HITSLOP_30} from '#/lib/constants'
|
import {HITSLOP_30} from '#/lib/constants'
|
||||||
import {useAppState} from '#/lib/hooks/useAppState'
|
import {useAppState} from '#/lib/hooks/useAppState'
|
||||||
|
import {clamp} from '#/lib/numbers'
|
||||||
import {logger} from '#/logger'
|
import {logger} from '#/logger'
|
||||||
import {useActiveVideoNative} from 'view/com/util/post-embeds/ActiveVideoNativeContext'
|
import {useActiveVideoNative} from 'view/com/util/post-embeds/ActiveVideoNativeContext'
|
||||||
import {atoms as a, useTheme} from '#/alf'
|
import {atoms as a, useTheme} from '#/alf'
|
||||||
|
@ -19,7 +21,12 @@ import {
|
||||||
} from '../../../../../../modules/expo-bluesky-swiss-army'
|
} from '../../../../../../modules/expo-bluesky-swiss-army'
|
||||||
import {TimeIndicator} from './TimeIndicator'
|
import {TimeIndicator} from './TimeIndicator'
|
||||||
|
|
||||||
export function VideoEmbedInnerNative() {
|
export function VideoEmbedInnerNative({
|
||||||
|
embed,
|
||||||
|
}: {
|
||||||
|
embed: AppBskyEmbedVideo.View
|
||||||
|
}) {
|
||||||
|
const {_} = useLingui()
|
||||||
const {player} = useActiveVideoNative()
|
const {player} = useActiveVideoNative()
|
||||||
const ref = useRef<VideoView>(null)
|
const ref = useRef<VideoView>(null)
|
||||||
const isScreenFocused = useIsFocused()
|
const isScreenFocused = useIsFocused()
|
||||||
|
@ -47,13 +54,23 @@ export function VideoEmbedInnerNative() {
|
||||||
ref.current?.enterFullscreen()
|
ref.current?.enterFullscreen()
|
||||||
}, [])
|
}, [])
|
||||||
|
|
||||||
|
let aspectRatio = 16 / 9
|
||||||
|
|
||||||
|
if (embed.aspectRatio) {
|
||||||
|
const {width, height} = embed.aspectRatio
|
||||||
|
aspectRatio = width / height
|
||||||
|
aspectRatio = clamp(aspectRatio, 1 / 1, 3 / 1)
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<View style={[a.flex_1, a.relative]}>
|
<View style={[a.flex_1, a.relative, {aspectRatio}]}>
|
||||||
<VideoView
|
<VideoView
|
||||||
ref={ref}
|
ref={ref}
|
||||||
player={player}
|
player={player}
|
||||||
style={[a.flex_1, a.rounded_sm]}
|
style={[a.flex_1, a.rounded_sm]}
|
||||||
|
contentFit="contain"
|
||||||
nativeControls={true}
|
nativeControls={true}
|
||||||
|
accessibilityIgnoresInvertColors
|
||||||
onEnterFullscreen={() => {
|
onEnterFullscreen={() => {
|
||||||
PlatformInfo.setAudioCategory(AudioCategory.Playback)
|
PlatformInfo.setAudioCategory(AudioCategory.Playback)
|
||||||
PlatformInfo.setAudioActive(true)
|
PlatformInfo.setAudioActive(true)
|
||||||
|
@ -65,13 +82,17 @@ export function VideoEmbedInnerNative() {
|
||||||
player.muted = true
|
player.muted = true
|
||||||
if (!player.playing) player.play()
|
if (!player.playing) player.play()
|
||||||
}}
|
}}
|
||||||
|
accessibilityLabel={
|
||||||
|
embed.alt ? _(msg`Video: ${embed.alt}`) : _(msg`Video`)
|
||||||
|
}
|
||||||
|
accessibilityHint=""
|
||||||
/>
|
/>
|
||||||
<Controls player={player} enterFullscreen={enterFullscreen} />
|
<VideoControls player={player} enterFullscreen={enterFullscreen} />
|
||||||
</View>
|
</View>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
function Controls({
|
function VideoControls({
|
||||||
player,
|
player,
|
||||||
enterFullscreen,
|
enterFullscreen,
|
||||||
}: {
|
}: {
|
||||||
|
|
|
@ -1,31 +1,27 @@
|
||||||
import React, {useEffect, useRef, useState} from 'react'
|
import React, {useEffect, useId, useRef, useState} from 'react'
|
||||||
import {View} from 'react-native'
|
import {View} from 'react-native'
|
||||||
|
import {AppBskyEmbedVideo} from '@atproto/api'
|
||||||
import Hls from 'hls.js'
|
import Hls from 'hls.js'
|
||||||
|
|
||||||
import {atoms as a} from '#/alf'
|
import {atoms as a} from '#/alf'
|
||||||
import {Controls} from './VideoWebControls'
|
import {Controls} from './VideoWebControls'
|
||||||
|
|
||||||
export function VideoEmbedInnerWeb({
|
export function VideoEmbedInnerWeb({
|
||||||
source,
|
embed,
|
||||||
active,
|
active,
|
||||||
setActive,
|
setActive,
|
||||||
onScreen,
|
onScreen,
|
||||||
}: {
|
}: {
|
||||||
source: string
|
embed: AppBskyEmbedVideo.View
|
||||||
active?: boolean
|
active: boolean
|
||||||
setActive?: () => void
|
setActive: () => void
|
||||||
onScreen?: boolean
|
onScreen: boolean
|
||||||
}) {
|
}) {
|
||||||
if (active == null || setActive == null || onScreen == null) {
|
|
||||||
throw new Error(
|
|
||||||
'active, setActive, and onScreen are required VideoEmbedInner props on web.',
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
const containerRef = useRef<HTMLDivElement>(null)
|
const containerRef = useRef<HTMLDivElement>(null)
|
||||||
const ref = useRef<HTMLVideoElement>(null)
|
const ref = useRef<HTMLVideoElement>(null)
|
||||||
const [focused, setFocused] = useState(false)
|
const [focused, setFocused] = useState(false)
|
||||||
const [hasSubtitleTrack, setHasSubtitleTrack] = useState(false)
|
const [hasSubtitleTrack, setHasSubtitleTrack] = useState(false)
|
||||||
|
const figId = useId()
|
||||||
|
|
||||||
const hlsRef = useRef<Hls | undefined>(undefined)
|
const hlsRef = useRef<Hls | undefined>(undefined)
|
||||||
|
|
||||||
|
@ -37,7 +33,7 @@ export function VideoEmbedInnerWeb({
|
||||||
hlsRef.current = hls
|
hlsRef.current = hls
|
||||||
|
|
||||||
hls.attachMedia(ref.current)
|
hls.attachMedia(ref.current)
|
||||||
hls.loadSource(source)
|
hls.loadSource(embed.playlist)
|
||||||
|
|
||||||
// initial value, later on it's managed by Controls
|
// initial value, later on it's managed by Controls
|
||||||
hls.autoLevelCapping = 0
|
hls.autoLevelCapping = 0
|
||||||
|
@ -53,29 +49,40 @@ export function VideoEmbedInnerWeb({
|
||||||
hls.detachMedia()
|
hls.detachMedia()
|
||||||
hls.destroy()
|
hls.destroy()
|
||||||
}
|
}
|
||||||
}, [source])
|
}, [embed.playlist])
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<View
|
<View style={[a.flex_1, a.rounded_sm, a.overflow_hidden]}>
|
||||||
style={[
|
<div ref={containerRef} style={{height: '100%', width: '100%'}}>
|
||||||
a.w_full,
|
<figure style={{margin: 0, position: 'absolute', inset: 0}}>
|
||||||
a.rounded_sm,
|
<video
|
||||||
// TODO: get from embed metadata
|
ref={ref}
|
||||||
// max should be 1 / 1
|
poster={embed.thumbnail}
|
||||||
{aspectRatio: 16 / 9},
|
style={{width: '100%', height: '100%', objectFit: 'contain'}}
|
||||||
a.overflow_hidden,
|
playsInline
|
||||||
]}>
|
preload="none"
|
||||||
<div
|
loop
|
||||||
ref={containerRef}
|
muted={!focused}
|
||||||
style={{width: '100%', height: '100%', display: 'flex'}}>
|
aria-labelledby={embed.alt ? figId : undefined}
|
||||||
<video
|
/>
|
||||||
ref={ref}
|
{embed.alt && (
|
||||||
style={{width: '100%', height: '100%', objectFit: 'contain'}}
|
<figcaption
|
||||||
playsInline
|
id={figId}
|
||||||
preload="none"
|
style={{
|
||||||
loop
|
position: 'absolute',
|
||||||
muted={!focused}
|
width: 1,
|
||||||
/>
|
height: 1,
|
||||||
|
padding: 0,
|
||||||
|
margin: -1,
|
||||||
|
overflow: 'hidden',
|
||||||
|
clip: 'rect(0, 0, 0, 0)',
|
||||||
|
whiteSpace: 'nowrap',
|
||||||
|
borderWidth: 0,
|
||||||
|
}}>
|
||||||
|
{embed.alt}
|
||||||
|
</figcaption>
|
||||||
|
)}
|
||||||
|
</figure>
|
||||||
<Controls
|
<Controls
|
||||||
videoRef={ref}
|
videoRef={ref}
|
||||||
hlsRef={hlsRef}
|
hlsRef={hlsRef}
|
||||||
|
|
|
@ -13,6 +13,7 @@ import {
|
||||||
AppBskyEmbedImages,
|
AppBskyEmbedImages,
|
||||||
AppBskyEmbedRecord,
|
AppBskyEmbedRecord,
|
||||||
AppBskyEmbedRecordWithMedia,
|
AppBskyEmbedRecordWithMedia,
|
||||||
|
AppBskyEmbedVideo,
|
||||||
AppBskyFeedDefs,
|
AppBskyFeedDefs,
|
||||||
AppBskyGraphDefs,
|
AppBskyGraphDefs,
|
||||||
moderateFeedGenerator,
|
moderateFeedGenerator,
|
||||||
|
@ -33,10 +34,12 @@ import {AutoSizedImage} from '../images/AutoSizedImage'
|
||||||
import {ImageLayoutGrid} from '../images/ImageLayoutGrid'
|
import {ImageLayoutGrid} from '../images/ImageLayoutGrid'
|
||||||
import {ExternalLinkEmbed} from './ExternalLinkEmbed'
|
import {ExternalLinkEmbed} from './ExternalLinkEmbed'
|
||||||
import {MaybeQuoteEmbed} from './QuoteEmbed'
|
import {MaybeQuoteEmbed} from './QuoteEmbed'
|
||||||
|
import {VideoEmbed} from './VideoEmbed'
|
||||||
|
|
||||||
type Embed =
|
type Embed =
|
||||||
| AppBskyEmbedRecord.View
|
| AppBskyEmbedRecord.View
|
||||||
| AppBskyEmbedImages.View
|
| AppBskyEmbedImages.View
|
||||||
|
| AppBskyEmbedVideo.View
|
||||||
| AppBskyEmbedExternal.View
|
| AppBskyEmbedExternal.View
|
||||||
| AppBskyEmbedRecordWithMedia.View
|
| AppBskyEmbedRecordWithMedia.View
|
||||||
| {$type: string; [k: string]: unknown}
|
| {$type: string; [k: string]: unknown}
|
||||||
|
@ -175,6 +178,14 @@ export function PostEmbeds({
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (AppBskyEmbedVideo.isView(embed)) {
|
||||||
|
return (
|
||||||
|
<ContentHider modui={moderation?.ui('contentMedia')}>
|
||||||
|
<VideoEmbed embed={embed} />
|
||||||
|
</ContentHider>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
return <View />
|
return <View />
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
49
yarn.lock
49
yarn.lock
|
@ -72,15 +72,15 @@
|
||||||
resolved "https://registry.yarnpkg.com/@atproto-labs/simple-store/-/simple-store-0.1.1.tgz#e743a2722b5d8732166f0a72aca8bd10e9bff106"
|
resolved "https://registry.yarnpkg.com/@atproto-labs/simple-store/-/simple-store-0.1.1.tgz#e743a2722b5d8732166f0a72aca8bd10e9bff106"
|
||||||
integrity sha512-WKILW2b3QbAYKh+w5U2x6p5FqqLl0nAeLwGeDY+KjX01K4Dq3vQTR9b/qNp0jZm48CabPQVrqCv0PPU9LgRRRg==
|
integrity sha512-WKILW2b3QbAYKh+w5U2x6p5FqqLl0nAeLwGeDY+KjX01K4Dq3vQTR9b/qNp0jZm48CabPQVrqCv0PPU9LgRRRg==
|
||||||
|
|
||||||
"@atproto/api@0.13.3":
|
"@atproto/api@0.13.5":
|
||||||
version "0.13.3"
|
version "0.13.5"
|
||||||
resolved "https://registry.yarnpkg.com/@atproto/api/-/api-0.13.3.tgz#d84f2a0e25f38cca59b69d178901634f2d20b4ff"
|
resolved "https://registry.yarnpkg.com/@atproto/api/-/api-0.13.5.tgz#04305cdb0a467ba366305c5e95cebb7ce0d39735"
|
||||||
integrity sha512-/PEVTTEQXICOjZCujAPsjArhwR0tR3LiF0SxxpZlWOjaqjVbqnBI/j0MNmddBFgeljC4/DcBobcDJ9HkILn4yQ==
|
integrity sha512-yT/YimcKYkrI0d282Zxo7O30OSYR+KDW89f81C6oYZfDRBcShC1aniVV8kluP5LrEAg8O27yrOSnBgx2v7XPew==
|
||||||
dependencies:
|
dependencies:
|
||||||
"@atproto/common-web" "^0.3.0"
|
"@atproto/common-web" "^0.3.0"
|
||||||
"@atproto/lexicon" "^0.4.1"
|
"@atproto/lexicon" "^0.4.1"
|
||||||
"@atproto/syntax" "^0.3.0"
|
"@atproto/syntax" "^0.3.0"
|
||||||
"@atproto/xrpc" "^0.6.0"
|
"@atproto/xrpc" "^0.6.1"
|
||||||
await-lock "^2.2.2"
|
await-lock "^2.2.2"
|
||||||
multiformats "^9.9.0"
|
multiformats "^9.9.0"
|
||||||
tlds "^1.234.0"
|
tlds "^1.234.0"
|
||||||
|
@ -443,6 +443,14 @@
|
||||||
"@atproto/lexicon" "^0.4.1"
|
"@atproto/lexicon" "^0.4.1"
|
||||||
zod "^3.23.8"
|
zod "^3.23.8"
|
||||||
|
|
||||||
|
"@atproto/xrpc@^0.6.1":
|
||||||
|
version "0.6.1"
|
||||||
|
resolved "https://registry.yarnpkg.com/@atproto/xrpc/-/xrpc-0.6.1.tgz#dcd1315c8c60eef5af2db7fa4e35a38ebc6d79d5"
|
||||||
|
integrity sha512-Zy5ydXEdk6sY7FDUZcEVfCL1jvbL4tXu5CcdPqbEaW6LQtk9GLds/DK1bCX9kswTGaBC88EMuqQMfkxOhp2t4A==
|
||||||
|
dependencies:
|
||||||
|
"@atproto/lexicon" "^0.4.1"
|
||||||
|
zod "^3.23.8"
|
||||||
|
|
||||||
"@aws-crypto/crc32@3.0.0":
|
"@aws-crypto/crc32@3.0.0":
|
||||||
version "3.0.0"
|
version "3.0.0"
|
||||||
resolved "https://registry.yarnpkg.com/@aws-crypto/crc32/-/crc32-3.0.0.tgz#07300eca214409c33e3ff769cd5697b57fdd38fa"
|
resolved "https://registry.yarnpkg.com/@aws-crypto/crc32/-/crc32-3.0.0.tgz#07300eca214409c33e3ff769cd5697b57fdd38fa"
|
||||||
|
@ -20681,7 +20689,16 @@ string-natural-compare@^3.0.1:
|
||||||
resolved "https://registry.yarnpkg.com/string-natural-compare/-/string-natural-compare-3.0.1.tgz#7a42d58474454963759e8e8b7ae63d71c1e7fdf4"
|
resolved "https://registry.yarnpkg.com/string-natural-compare/-/string-natural-compare-3.0.1.tgz#7a42d58474454963759e8e8b7ae63d71c1e7fdf4"
|
||||||
integrity sha512-n3sPwynL1nwKi3WJ6AIsClwBMa0zTi54fn2oLU6ndfTSIO05xaznjSf15PcBZU6FNWbmN5Q6cxT4V5hGvB4taw==
|
integrity sha512-n3sPwynL1nwKi3WJ6AIsClwBMa0zTi54fn2oLU6ndfTSIO05xaznjSf15PcBZU6FNWbmN5Q6cxT4V5hGvB4taw==
|
||||||
|
|
||||||
"string-width-cjs@npm:string-width@^4.2.0", string-width@^4.1.0, string-width@^4.2.0, string-width@^4.2.3:
|
"string-width-cjs@npm:string-width@^4.2.0":
|
||||||
|
version "4.2.3"
|
||||||
|
resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010"
|
||||||
|
integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==
|
||||||
|
dependencies:
|
||||||
|
emoji-regex "^8.0.0"
|
||||||
|
is-fullwidth-code-point "^3.0.0"
|
||||||
|
strip-ansi "^6.0.1"
|
||||||
|
|
||||||
|
string-width@^4.1.0, string-width@^4.2.0, string-width@^4.2.3:
|
||||||
version "4.2.3"
|
version "4.2.3"
|
||||||
resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010"
|
resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010"
|
||||||
integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==
|
integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==
|
||||||
|
@ -20790,7 +20807,7 @@ stringify-object@^3.3.0:
|
||||||
is-obj "^1.0.1"
|
is-obj "^1.0.1"
|
||||||
is-regexp "^1.0.0"
|
is-regexp "^1.0.0"
|
||||||
|
|
||||||
"strip-ansi-cjs@npm:strip-ansi@^6.0.1", strip-ansi@^6.0.0, strip-ansi@^6.0.1:
|
"strip-ansi-cjs@npm:strip-ansi@^6.0.1":
|
||||||
version "6.0.1"
|
version "6.0.1"
|
||||||
resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9"
|
resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9"
|
||||||
integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==
|
integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==
|
||||||
|
@ -20804,6 +20821,13 @@ strip-ansi@^5.0.0, strip-ansi@^5.2.0:
|
||||||
dependencies:
|
dependencies:
|
||||||
ansi-regex "^4.1.0"
|
ansi-regex "^4.1.0"
|
||||||
|
|
||||||
|
strip-ansi@^6.0.0, strip-ansi@^6.0.1:
|
||||||
|
version "6.0.1"
|
||||||
|
resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9"
|
||||||
|
integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==
|
||||||
|
dependencies:
|
||||||
|
ansi-regex "^5.0.1"
|
||||||
|
|
||||||
strip-ansi@^7.0.1:
|
strip-ansi@^7.0.1:
|
||||||
version "7.1.0"
|
version "7.1.0"
|
||||||
resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-7.1.0.tgz#d5b6568ca689d8561370b0707685d22434faff45"
|
resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-7.1.0.tgz#d5b6568ca689d8561370b0707685d22434faff45"
|
||||||
|
@ -22536,7 +22560,7 @@ workbox-window@6.6.1:
|
||||||
"@types/trusted-types" "^2.0.2"
|
"@types/trusted-types" "^2.0.2"
|
||||||
workbox-core "6.6.1"
|
workbox-core "6.6.1"
|
||||||
|
|
||||||
"wrap-ansi-cjs@npm:wrap-ansi@^7.0.0", wrap-ansi@^7.0.0:
|
"wrap-ansi-cjs@npm:wrap-ansi@^7.0.0":
|
||||||
version "7.0.0"
|
version "7.0.0"
|
||||||
resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43"
|
resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43"
|
||||||
integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==
|
integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==
|
||||||
|
@ -22554,6 +22578,15 @@ wrap-ansi@^6.2.0:
|
||||||
string-width "^4.1.0"
|
string-width "^4.1.0"
|
||||||
strip-ansi "^6.0.0"
|
strip-ansi "^6.0.0"
|
||||||
|
|
||||||
|
wrap-ansi@^7.0.0:
|
||||||
|
version "7.0.0"
|
||||||
|
resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43"
|
||||||
|
integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==
|
||||||
|
dependencies:
|
||||||
|
ansi-styles "^4.0.0"
|
||||||
|
string-width "^4.1.0"
|
||||||
|
strip-ansi "^6.0.0"
|
||||||
|
|
||||||
wrap-ansi@^8.0.1, wrap-ansi@^8.1.0:
|
wrap-ansi@^8.0.1, wrap-ansi@^8.1.0:
|
||||||
version "8.1.0"
|
version "8.1.0"
|
||||||
resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-8.1.0.tgz#56dc22368ee570face1b49819975d9b9a5ead214"
|
resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-8.1.0.tgz#56dc22368ee570face1b49819975d9b9a5ead214"
|
||||||
|
|
Loading…
Reference in New Issue