-
Notifications
You must be signed in to change notification settings - Fork 133
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1257 from canalplus/fix/ps5-loaded
PS5: wait for a readyState of `4` before considering the content loaded
- Loading branch information
Showing
4 changed files
with
59 additions
and
1 deletion.
There are no files selected for viewing
36 changes: 36 additions & 0 deletions
36
src/compat/__tests__/should_wait_for_have_enough_data.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/* eslint-disable @typescript-eslint/no-unsafe-assignment */ | ||
/* eslint-disable @typescript-eslint/no-unsafe-member-access */ | ||
/* eslint-disable @typescript-eslint/no-var-requires */ | ||
/* eslint-disable @typescript-eslint/no-unsafe-call */ | ||
/* eslint-disable @typescript-eslint/no-unsafe-assignment */ | ||
/* eslint-disable @typescript-eslint/no-unsafe-return */ | ||
|
||
describe("compat - shouldWaitForHaveEnoughData", () => { | ||
beforeEach(() => { | ||
jest.resetModules(); | ||
}); | ||
|
||
it("should return false if we are not on the Playstation 5", () => { | ||
jest.mock("../browser_detection", () => { | ||
return { | ||
__esModule: true as const, | ||
isPlayStation5: false, | ||
}; | ||
}); | ||
const shouldWaitForHaveEnoughData = | ||
jest.requireActual("../should_wait_for_have_enough_data"); | ||
expect(shouldWaitForHaveEnoughData.default()).toBe(false); | ||
}); | ||
|
||
it("should return true if we are on the Playstation 5", () => { | ||
jest.mock("../browser_detection", () => { | ||
return { | ||
__esModule: true as const, | ||
isPlayStation5: true, | ||
}; | ||
}); | ||
const shouldWaitForHaveEnoughData = | ||
jest.requireActual("../should_wait_for_have_enough_data"); | ||
expect(shouldWaitForHaveEnoughData.default()).toBe(true); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { isPlayStation5 } from "./browser_detection"; | ||
|
||
/** | ||
* An `HTMLMediaElement`'s readyState allows the browser to communicate whether | ||
* it can play a content reliably. | ||
* Usually, we may consider that a `HAVE_FUTURE_DATA` (readyState `3`) or even | ||
* a `HAVE_CURRENT_DATA` (readyState `2`) is enough to begin playing the content | ||
* and consider it as loaded. | ||
* | ||
* However some devices wrongly anounce those readyStates before being actually | ||
* able to decode the content. For those devices we wait for the | ||
* `HAVE_ENOUGH_DATA` readyState before considering the content as loaded. | ||
* @returns {boolean} | ||
*/ | ||
export default function shouldWaitForHaveEnoughData() : boolean { | ||
return isPlayStation5; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters