Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions apps/frontend/app/_player/Player.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -317,16 +317,16 @@ interface AirPlayAvailabilityEvent extends Event {

/**
* Build the master playlist URL for a channel; respects the optional
* `quality` pin by appending `?profile=<profile>`. `auto` requests the
* multivariant graph so hls.js can change renditions before buffer exhaustion.
* `quality` pin by appending `?profile=<profile>`. `auto` retains the proven
* single-stream browser conversion; explicit quality choices remain available.
*/
function buildSrc(
channelId: string,
quality: PlayerQuality | undefined,
viewerId?: string
): string {
const base = `/api/v1/stream/${encodeURIComponent(channelId)}/master.m3u8`;
const profile = !quality || quality === "auto" ? "auto" : quality;
const profile = !quality || quality === "auto" ? "original-quality" : quality;
const search = new URLSearchParams({ profile });
if (viewerId) {
search.set("viewerId", viewerId);
Expand Down Expand Up @@ -378,7 +378,8 @@ function buildViewerReleaseUrl(
quality: PlayerQuality,
viewerId: string
): string {
const query = new URLSearchParams({ profile: quality });
const profile = quality === "auto" ? "original-quality" : quality;
const query = new URLSearchParams({ profile });
return `/api/v1/stream/${encodeURIComponent(channelId)}/viewers/${encodeURIComponent(viewerId)}/release?${query.toString()}`;
}

Expand Down
12 changes: 6 additions & 6 deletions apps/frontend/tests/player/Player.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ describe("Player", () => {
([source]) => source as string
);
expect(sources).toHaveLength(1);
expectLiveSource(sources[0]!, CHANNEL_ID, "auto");
expectLiveSource(sources[0]!, CHANNEL_ID, "original-quality");
expect(
new URL(sources[0]!, "http://localhost").searchParams.get("viewerId")
).toBe(clientViewerId);
Expand All @@ -169,11 +169,11 @@ describe("Player", () => {
const instance = fakeInstances[0]!;
expect(instance.attachMedia).toHaveBeenCalled();
const source = instance.loadSource.mock.calls[0]?.[0] as string;
const viewerId = expectLiveSource(source, CHANNEL_ID, "auto");
const viewerId = expectLiveSource(source, CHANNEL_ID, "original-quality");

unmount();
expect(sendBeacon).toHaveBeenCalledWith(
`/api/v1/stream/${CHANNEL_ID}/viewers/${viewerId}/release?profile=auto`
`/api/v1/stream/${CHANNEL_ID}/viewers/${viewerId}/release?profile=original-quality`
);
});

Expand Down Expand Up @@ -205,7 +205,7 @@ describe("Player", () => {
expectLiveSource(
fakeInstances[0]?.loadSource.mock.calls[0]?.[0] as string,
CHANNEL_ID,
"auto"
"original-quality"
);
expect(screen.queryByTestId("player-error")).not.toBeInTheDocument();
});
Expand All @@ -222,7 +222,7 @@ describe("Player", () => {

await waitFor(() => expect(FakeHls.isSupported).toHaveBeenCalled());
expect(fakeInstances).toHaveLength(0);
expectLiveSource(video.src, CHANNEL_ID, "auto");
expectLiveSource(video.src, CHANNEL_ID, "original-quality");
});

it("explains when neither HLS playback engine is supported", async () => {
Expand Down Expand Up @@ -554,7 +554,7 @@ describe("Player", () => {
instance.loadSource.mock.calls.length - 1
]?.[0] as string,
"00000000-0000-4000-8000-000000000002",
"auto"
"original-quality"
);
});

Expand Down
Loading