Bluesky app fork with some witchin' additions 💫
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Share bandwidth estimate between video instances (#8377)

authored by

Samuel Newman and committed by
GitHub
7b3916c8 bc42d26b

+22 -1
+11 -1
src/view/com/util/post-embeds/VideoEmbedInner/VideoEmbedInnerWeb.tsx
··· 1 1 import React, {useEffect, useId, useRef, useState} from 'react' 2 2 import {View} from 'react-native' 3 - import {AppBskyEmbedVideo} from '@atproto/api' 3 + import {type AppBskyEmbedVideo} from '@atproto/api' 4 4 import {msg} from '@lingui/macro' 5 5 import {useLingui} from '@lingui/react' 6 6 import type * as HlsTypes from 'hls.js' ··· 8 8 import {useNonReactiveCallback} from '#/lib/hooks/useNonReactiveCallback' 9 9 import {atoms as a} from '#/alf' 10 10 import {MediaInsetBorder} from '#/components/MediaInsetBorder' 11 + import * as BandwidthEstimate from './bandwidth-estimate' 11 12 import {Controls} from './web-controls/VideoControls' 12 13 13 14 export function VideoEmbedInnerWeb({ ··· 231 232 }) 232 233 hlsRef.current = hls 233 234 235 + const latestEstimate = BandwidthEstimate.get() 236 + if (latestEstimate !== undefined) { 237 + hls.bandwidthEstimate = latestEstimate 238 + } 239 + 234 240 hls.attachMedia(videoRef.current) 235 241 hls.loadSource(playlist) 236 242 ··· 247 253 }, 248 254 {signal}, 249 255 ) 256 + 257 + hls.on(Hls.Events.FRAG_LOADED, () => { 258 + BandwidthEstimate.set(hls.bandwidthEstimate) 259 + }) 250 260 251 261 hls.on(Hls.Events.SUBTITLE_TRACKS_UPDATED, (_event, data) => { 252 262 if (data.subtitleTracks.length > 0) {
+11
src/view/com/util/post-embeds/VideoEmbedInner/bandwidth-estimate.ts
··· 1 + let latestBandwidthEstimate: number | undefined 2 + 3 + export function get() { 4 + return latestBandwidthEstimate 5 + } 6 + 7 + export function set(estimate: number) { 8 + if (!isNaN(estimate)) { 9 + latestBandwidthEstimate = estimate 10 + } 11 + }