Hi @Hari_Krishnan,
Thank you for your patience while we investigated this. Vega OS does support rendering a transparent WebView on top of video playback, which is exactly the pattern you need for overlaying UI controls over KeplerVideoSurfaceView.
How It Works
The approach is to layer a WebView (from @amazon-devices/webview) as a sibling on top of KeplerVideoSurfaceView, with the WebView set to a fully transparent background. The video shows through the transparent WebView, while your HTML-based controls render on top.
Steps to Implement
- Update your Metro config - Add
'html'to theassetExtsresolver so Metro can bundle local HTML files as assets:
const defaultConfig = getDefaultConfig(__dirname);
const config = {
resolver: {
assetExts: defaultConfig.resolver.assetExts.includes('html')
? defaultConfig.resolver.assetExts
: [...defaultConfig.resolver.assetExts, 'html'],
},
};
module.exports = mergeConfig(defaultConfig, config);
- Load your HTML overlay as an asset source - Use
Image.resolveAssetSourceto resolve the local HTML file:
import {Image} from 'react-native';
const overlaySource = {
uri: Image.resolveAssetSource(require('../assets/player-overlay.html')).uri,
};
- Layer the components - Place
KeplerVideoViewand a transparent WebView container as siblings inside the same parentView:
<View style={styles.container}>
{useKeplerVideoView ? (
<KeplerVideoView style={styles.backgroundVideo} videoPlayer={video.current} />
) : null}
<View style={styles.modalContainer}>
<WebView
ref={webRef}
source={overlaySource}
style={styles.overlayWebView}
onMessage={handleTransportMessage}
onLoadStart={() => setIsWebViewReady(false)}
onLoad={() => setIsWebViewReady(true)}
/>
</View>
</View>
- Key styles - The WebView and its container must both have transparent backgrounds:
const styles = StyleSheet.create({
container: { flex: 1 },
overlayWebView: {
flex: 1,
backgroundColor: 'rgb(0,0,0, 0)',
},
modalContainer: {
flex: 1,
backgroundColor: 'rgba(0, 0, 0, 0)',
position: 'absolute',
top: 0,
left: 0,
width: 1920,
height: 1080,
},
});
-
Handle TV remote input - Use
useTVEventHandlerfrom@amazon-devices/react-native-keplerto capture remote control events (e.g., the select button) and forward them into the WebView viainjectJavaScript. -
Bidirectional communication - Your HTML overlay should send messages back to React Native using
window.ReactNativeWebView.postMessage(...), and your React Native side should handle them via the WebView’sonMessageprop. To push state updates into the WebView, usewebRef.current.injectJavaScript(...). -
Track WebView readiness - Gate all
injectJavaScriptcalls behind anisWebViewReadystate flag (set totrueinonLoad,falseinonLoadStart) to avoid calling into the WebView before it’s ready. -
Create your own HTML overlay page - Your HTML file should set
background: transparenton bothhtmlandbodyelements. Only your actual control elements (buttons, text) should have visible styling. The HTML should expose functions that React Native can call viainjectJavaScriptand usepostMessageto send user actions back.
This requires @amazon-devices/webview for the WebView component
This requires @amazon-devices/react-native-kepler for useTVEventHandler
Note: The code example uses KeplerVideoView (from @amazon-devices/react-native-w3cmedia), which is the component used for video rendering.
Let us know if you have any further questions!
Warm regards,
Aishwarya