diff --git a/e2e/src/utils/Actions.ts b/e2e/src/utils/Actions.ts index 38b4c4f8f..09925b1d4 100644 --- a/e2e/src/utils/Actions.ts +++ b/e2e/src/utils/Actions.ts @@ -1,6 +1,16 @@ // noinspection JSUnusedGlobalSymbols -import { ErrorEvent, type Event, EventMap, PlayerEventType, SourceDescription, StringKeyOf, THEOplayer } from 'react-native-theoplayer'; +import { + AdEvent, + AdEventType, + ErrorEvent, + type Event, + EventMap, + PlayerEventType, + SourceDescription, + StringKeyOf, + THEOplayer, +} from 'react-native-theoplayer'; import { getTestPlayer } from '../components/TestableTHEOplayerView'; import { logPlayerBuffer } from './PlayerUtils'; @@ -74,7 +84,14 @@ export const waitForPlayerEvents = async >( player.removeEventListener(PlayerEventType.ERROR, onError); reject(err); }; - + const onAdError = (e: AdEvent) => { + if (e.subType === AdEventType.AD_ERROR) { + const err = 'Ad error'; + console.error('[waitForPlayerEvents]', err); + player.removeEventListener(PlayerEventType.AD_EVENT, onAdError); + reject(err); + } + }; const TAG: string = `[waitForPlayerEvents] eventList ${eventListIndex}:`; eventListIndex += 1; @@ -126,6 +143,7 @@ export const waitForPlayerEvents = async >( console.debug(TAG, `Added listener for ${eventType} to the player`); }); player.addEventListener(PlayerEventType.ERROR, onError); + player.addEventListener(PlayerEventType.AD_EVENT, onAdError); }); // Add rejection on time-out @@ -163,7 +181,12 @@ const withPlayerStateLogOnError = async (player: THEOplayer, promise: Promise