Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Note: This PR is based on #4765 (feat: add DAI support) by @maciekBudzinski
Summary
This PR adds Dynamic Ad Insertion (DAI) support for both Android and iOS, while also unifying the ad configuration API.
Motivation
Right now, react-native-video only supports client-side ad insertion (CSAI) where the player requests ads separately and plays them during breaks. Adding DAI support enables server-side ad insertion, expanding the types of ads that can be used with react-native-video.
This is also a feature requested by the community: #4399
Changes
Breaking Change: Unified Ad Configuration API
The ad configuration has been unified into a single
source.adproperty with atypediscriminator:Before (CSAI only):
After (CSAI):
After (DAI VOD):
After (DAI Live):
JS
AdConfigCSAI,AdConfigDAI,AdConfigDAIVod,AdConfigDAILive)Videocomponent to normalize ad configuration and handle both CSAI and DAI through the unifiedsource.adpropformatproperty to DAI configuration for HLS/DASH stream format selection (Android only)iOS
AdParamsdata structure to parse and store ad configuration from React Native bridgeadTagParametersAndroid
AdsPropsKotlin class to parse unified ad configuration with DAI propertiesImaServerSideAdInsertionMediaSource) for both VOD and Live streamsformatproperty support for HLS/DASH stream format selection viaImaServerSideAdInsertionUriBuilderwait()call in DAI initialization that could cause issues1.4.1to1.8.0to support DAI featuresTesting App
examples/expo-dai/) demonstrating DAI functionalityDocumentation
source.adprop documentation with both CSAI and DAI configuration optionsformatproperty documentation for DAI streamsadTagUrlandadLanguageprops as deprecatedTest Plan
A complete test app is available at
examples/expo-dai/that demonstrates DAI functionality with both VOD and Live streams. The app includes a UI for configuring DAI parameters (including format selection), real-time event logging, and controls for testing various playback scenarios. The README inexamples/expo-dai/is worth reading before testing as it contains important setup instructions, usage guidelines, and known issues.Key Testing Scenarios:
contentSourceIdandvideoIdplay correctly on both iOS and AndroidassetKeyplay correctly on both iOS and AndroidonReceiveAdEventcallbackfallbackUriwhen DAI stream fails to loadadTagParametersare correctly passed through to the IMA SDKadTagUrlprop still works (with deprecation warning in docs)Note: Picture-in-Picture testing requires a real iOS device as simulators don't reliably support PiP. Google's official sample streams may have known issues with HLS VOD streams stopping around 1:10 (documented in the example app README).