Skip to content

Commit

Permalink
Add extra player logging
Browse files Browse the repository at this point in the history
  • Loading branch information
tvanlaerhoven committed Dec 23, 2024
1 parent 9447d12 commit 5c564f3
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions e2e/src/components/TestableTHEOplayerView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { THEOplayer, THEOplayerView, THEOplayerViewProps } from 'react-native-th
import React, { useCallback } from 'react';

let testPlayer: THEOplayer | undefined = undefined;
let testPlayerId: number = 0;

/**
* Wait until the player is ready.
Expand All @@ -17,6 +18,7 @@ export const getTestPlayer = async (timeout = 5000, poll = 200): Promise<THEOpla
setTimeout(() => {
if (testPlayer) {
// Player is ready.
console.debug(`[checkPlayer] ready id: ${testPlayerId}`);
resolve(testPlayer);
} else if (Date.now() - start > timeout) {
// Too late.
Expand All @@ -34,11 +36,14 @@ export const getTestPlayer = async (timeout = 5000, poll = 200): Promise<THEOpla
export const TestableTHEOplayerView = (props: THEOplayerViewProps) => {
const generateTestHook = useCavy();
const onPlayerReady = useCallback((player: THEOplayer) => {
testPlayerId++;
testPlayer = player;
console.debug(`[onPlayerReady] id: ${testPlayerId}`);
props.onPlayerReady?.(player);
}, []);

const onPlayerDestroy = useCallback(() => {
console.debug(`[onPlayerDestroy] id: ${testPlayerId}`);
testPlayer = undefined;
}, []);

Expand Down

0 comments on commit 5c564f3

Please sign in to comment.