Merge remote-tracking branch 'origin/main' into hailey/feed-metrics

This commit is contained in:
Hailey
2025-05-29 14:44:17 -07:00
2 changed files with 22 additions and 1 deletions
@@ -1,6 +1,6 @@
import React, {useEffect, useId, useRef, useState} from 'react'
import {View} from 'react-native'
import {AppBskyEmbedVideo} from '@atproto/api'
import {type AppBskyEmbedVideo} from '@atproto/api'
import {msg} from '@lingui/macro'
import {useLingui} from '@lingui/react'
import type * as HlsTypes from 'hls.js'
@@ -8,6 +8,7 @@ import type * as HlsTypes from 'hls.js'
import {useNonReactiveCallback} from '#/lib/hooks/useNonReactiveCallback'
import {atoms as a} from '#/alf'
import {MediaInsetBorder} from '#/components/MediaInsetBorder'
import * as BandwidthEstimate from './bandwidth-estimate'
import {Controls} from './web-controls/VideoControls'
export function VideoEmbedInnerWeb({
@@ -231,6 +232,11 @@ function useHLS({
})
hlsRef.current = hls
const latestEstimate = BandwidthEstimate.get()
if (latestEstimate !== undefined) {
hls.bandwidthEstimate = latestEstimate
}
hls.attachMedia(videoRef.current)
hls.loadSource(playlist)
@@ -248,6 +254,10 @@ function useHLS({
{signal},
)
hls.on(Hls.Events.FRAG_LOADED, () => {
BandwidthEstimate.set(hls.bandwidthEstimate)
})
hls.on(Hls.Events.SUBTITLE_TRACKS_UPDATED, (_event, data) => {
if (data.subtitleTracks.length > 0) {
setHasSubtitleTrack(true)
@@ -0,0 +1,11 @@
let latestBandwidthEstimate: number | undefined
export function get() {
return latestBandwidthEstimate
}
export function set(estimate: number) {
if (!isNaN(estimate)) {
latestBandwidthEstimate = estimate
}
}