diff --git a/index.d.ts b/index.d.ts index 5e00e80..8762f8e 100644 --- a/index.d.ts +++ b/index.d.ts @@ -1,21 +1,21 @@ -import React from 'react'; -import {StyleProp, ViewStyle} from 'react-native'; -import {WebViewProps} from 'react-native-webview'; +import React from "react"; +import { StyleProp, ViewStyle } from "react-native"; +import { WebViewProps } from "react-native-webview"; export enum PLAYER_STATES { - ENDED = 'ended', - PAUSED = 'paused', - PLAYING = 'playing', - UNSTARTED = 'unstarted', - BUFFERING = 'buffering', - VIDEO_CUED = 'video cued', + ENDED = "ended", + PAUSED = "paused", + PLAYING = "playing", + UNSTARTED = "unstarted", + BUFFERING = "buffering", + VIDEO_CUED = "video cued", } export enum PLAYER_ERRORS { - HTML5_ERROR = 'HTML5_error', - VIDEO_NOT_FOUND = 'video_not_found', - EMBED_NOT_ALLOWED = 'embed_not_allowed', - INVALID_PARAMETER = 'invalid_parameter', + HTML5_ERROR = "HTML5_error", + VIDEO_NOT_FOUND = "video_not_found", + EMBED_NOT_ALLOWED = "embed_not_allowed", + INVALID_PARAMETER = "invalid_parameter", } export interface YoutubeIframeRef { @@ -40,7 +40,7 @@ export interface InitialPlayerParams { preventFullScreen?: boolean; playerLang?: String; iv_load_policy?: Number; - /** + /** * @deprecated - This parameter has no effect since August 15, 2023 * https://developers.google.com/youtube/player_parameters#modestbranding */ @@ -163,6 +163,10 @@ export interface YoutubeIframeProps { * * for code check "iframe.html" in package repo */ baseUrlOverride?: string; + /** + * the headers that will be used in the webview request + */ + headers? : Record; } export interface YoutubeMeta { diff --git a/src/YoutubeIframe.js b/src/YoutubeIframe.js index 4bbf487..85953c7 100644 --- a/src/YoutubeIframe.js +++ b/src/YoutubeIframe.js @@ -45,6 +45,7 @@ const YoutubeIframe = (props, ref) => { onFullScreenChange = _status => {}, onPlaybackQualityChange = _quality => {}, onPlaybackRateChange = _playbackRate => {}, + headers, } = props; const [playerReady, setPlayerReady] = useState(false); @@ -272,7 +273,7 @@ const YoutubeIframe = (props, ref) => { const base = baseUrlOverride || DEFAULT_BASE_URL; const data = ytScript.urlEncodedJSON; - return {uri: base + '?data=' + data}; + return {uri: base + '?data=' + data, headers}; }, [useLocalHTML, contentScale, baseUrlOverride, allowWebViewZoom]); return (