Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 18 additions & 14 deletions index.d.ts
Original file line number Diff line number Diff line change
@@ -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 {
Expand All @@ -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
*/
Expand Down Expand Up @@ -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<string, string>;
}

export interface YoutubeMeta {
Expand Down
3 changes: 2 additions & 1 deletion src/YoutubeIframe.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ const YoutubeIframe = (props, ref) => {
onFullScreenChange = _status => {},
onPlaybackQualityChange = _quality => {},
onPlaybackRateChange = _playbackRate => {},
headers,
} = props;

const [playerReady, setPlayerReady] = useState(false);
Expand Down Expand Up @@ -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 (
Expand Down