tangled
alpha
login
or
join now
stream.place
/
streamplace
74
fork
atom
Live video on the AT Protocol
74
fork
atom
overview
issues
1
pulls
pipelines
resolution display for source
Natalie B.
1 month ago
2dd151ef
9b8591e5
+30
-2
1 changed file
expand all
collapse all
unified
split
js
components
src
components
mobile-player
ui
viewer-context-menu.tsx
+30
-2
js/components/src/components/mobile-player/ui/viewer-context-menu.tsx
···
58
58
const setReportModalOpen = usePlayerStore((x) => x.setReportModalOpen);
59
59
const setReportSubject = usePlayerStore((x) => x.setReportSubject);
60
60
61
61
+
const latestSegment = useLivestreamStore((x) => x.segment);
62
62
+
// get highest height x width rendition for video
63
63
+
const videoRendition = latestSegment?.video?.reduce((prev, current) => {
64
64
+
const prevPixels = prev.width * prev.height;
65
65
+
const currentPixels = current.width * current.height;
66
66
+
return currentPixels > prevPixels ? current : prev;
67
67
+
}, latestSegment?.video?.[0]);
68
68
+
const highestLength = videoRendition
69
69
+
? videoRendition.height < videoRendition.width
70
70
+
? videoRendition.height
71
71
+
: videoRendition?.width
72
72
+
: 0;
73
73
+
74
74
+
// ugh i hate this
75
75
+
const frames = videoRendition?.framerate as
76
76
+
| { num: number; den: number }
77
77
+
| undefined;
78
78
+
const fps =
79
79
+
frames?.num && frames?.den
80
80
+
? Math.round((frames.num / frames.den) * 100) / 100
81
81
+
: 0;
82
82
+
83
83
+
const resolutionDisplay = highestLength
84
84
+
? `(${highestLength}p${fps > 0 ? fps : ""})`
85
85
+
: "(Original Quality)";
86
86
+
61
87
const { profile } = useLivestreamInfo();
62
88
63
89
const avatars = useAvatars(profile?.did ? [profile?.did] : []);
···
215
241
>
216
242
<Text>Quality</Text>
217
243
<Text muted size={isMobile ? "base" : "sm"}>
218
218
-
{quality === "source" ? "Source" : quality},{" "}
244
244
+
{quality === "source"
245
245
+
? `Source${resolutionDisplay ? " " + resolutionDisplay + "\n" : ", "}`
246
246
+
: quality}
219
247
{lowLatency ? "Low Latency" : ""}
220
248
</Text>
221
249
</View>
···
227
255
onValueChange={setQuality}
228
256
>
229
257
<DropdownMenuRadioItem value="source">
230
230
-
<Text>Source (Original Quality)</Text>
258
258
+
<Text>Source {resolutionDisplay}</Text>
231
259
</DropdownMenuRadioItem>
232
260
{qualities.map((r) => (
233
261
<DropdownMenuRadioItem key={r.name} value={r.name}>