|
1 | 1 | import React from 'react'; |
2 | 2 | import {WebViewProps} from 'react-native-webview'; |
| 3 | +import {StyleProp, ViewStyle} from 'react-native'; |
3 | 4 |
|
4 | 5 | export interface InitialPlayerParams { |
5 | | - loop: boolean; |
6 | | - controls: boolean; |
7 | | - cc_lang_pref: string; |
8 | | - showClosedCaptions: boolean; |
9 | | - color: string; |
10 | | - start: Number; |
11 | | - end: Number; |
12 | | - preventFullScreen: boolean; |
13 | | - playerLang: String; |
14 | | - iv_load_policy: Number; |
15 | | - modestbranding: boolean; |
16 | | - rel: boolean; |
| 6 | + loop?: boolean; |
| 7 | + controls?: boolean; |
| 8 | + cc_lang_pref?: string; |
| 9 | + showClosedCaptions?: boolean; |
| 10 | + color?: string; |
| 11 | + start?: Number; |
| 12 | + end?: Number; |
| 13 | + preventFullScreen?: boolean; |
| 14 | + playerLang?: String; |
| 15 | + iv_load_policy?: Number; |
| 16 | + modestbranding?: boolean; |
| 17 | + rel?: boolean; |
17 | 18 | } |
18 | 19 |
|
19 | 20 | export interface YoutubeIframeProps { |
@@ -42,65 +43,80 @@ export interface YoutubeIframeProps { |
42 | 43 | * @example |
43 | 44 | * playList={['QRt7LjqJ45k', 'fHsa9DqmId8']} |
44 | 45 | */ |
45 | | - playList: Array<String> | String; |
| 46 | + playList?: Array<String> | String; |
46 | 47 | /** |
47 | 48 | * Flag to tell the player to play or pause the video. |
48 | 49 | */ |
49 | | - play: Boolean; |
| 50 | + play?: Boolean; |
50 | 51 |
|
51 | 52 | /** |
52 | 53 | * Flag to tell the player to mute the video. |
53 | 54 | */ |
54 | | - mute: Boolean; |
| 55 | + mute?: Boolean; |
55 | 56 | /** |
56 | 57 | * Sets the volume. Accepts an integer between `0` and `100`. |
57 | 58 | */ |
58 | | - volume: Number; |
| 59 | + volume?: Number; |
59 | 60 | /** |
60 | 61 | * A style prop that will be given to the webview |
61 | 62 | */ |
62 | | - webViewStyle: any; |
| 63 | + webViewStyle?: StyleProp<ViewStyle>; |
63 | 64 | /** |
64 | 65 | * Props that are supplied to the underlying webview (react-native-webview). A full list of props can be found [here](https://github.com/react-native-community/react-native-webview/blob/master/docs/Reference.md#props-index) |
65 | 66 | */ |
66 | | - webViewProps: WebViewProps; |
| 67 | + webViewProps?: WebViewProps; |
67 | 68 | /** |
68 | 69 | * This sets the suggested playback rate for the current video. If the playback rate changes, it will only change for the video that is already cued or being played. |
69 | 70 | */ |
70 | | - playbackRate: Number; |
| 71 | + playbackRate?: Number; |
71 | 72 | /** |
72 | 73 | * This event fires if an error occurs in the player. The API will pass an error string to the event listener function. |
73 | 74 | */ |
74 | | - onError: (error: string) => void; |
| 75 | + onError?: (error: string) => void; |
75 | 76 | /** |
76 | 77 | * This event fires whenever a player has finished loading and is ready. |
77 | 78 | */ |
78 | | - onReady: () => void; |
| 79 | + onReady?: () => void; |
79 | 80 | /** |
80 | 81 | * Starts the playlist from the given index |
81 | 82 | * |
82 | 83 | * Works only if the playlist is a list of video IDs. |
83 | 84 | */ |
84 | | - playListStartIndex: Number; |
| 85 | + playListStartIndex?: Number; |
85 | 86 | initialPlayerParams: InitialPlayerParams; |
86 | 87 | /** |
87 | 88 | * Changes user string to make autoplay work on the iframe player for some android devices. |
88 | 89 | */ |
89 | | - forceAndroidAutoplay: Boolean; |
| 90 | + forceAndroidAutoplay?: Boolean; |
90 | 91 | /** |
91 | 92 | * callback for when the player's state changes. |
92 | 93 | */ |
93 | | - onChangeState: (event: String) => void; |
| 94 | + onChangeState?: (event: String) => void; |
94 | 95 | /** |
95 | 96 | * callback for when the video playback quality changes. It might signal a change in the viewer's playback environment. |
96 | 97 | */ |
97 | | - onPlaybackQualityChange: (quality: String) => void; |
| 98 | + onPlaybackQualityChange?: (quality: String) => void; |
98 | 99 | /** |
99 | 100 | * callback for when the video playback rate changes. |
100 | 101 | */ |
101 | | - onPlaybackRateChange: (event: String) => void; |
| 102 | + onPlaybackRateChange?: (event: String) => void; |
102 | 103 | } |
103 | 104 |
|
104 | 105 | declare const YoutubeIframe: React.SFC<YoutubeIframeProps>; |
105 | 106 |
|
106 | 107 | export default YoutubeIframe; |
| 108 | + |
| 109 | +export function getYoutubeMeta (id: string): { |
| 110 | + "thumbnail_width": number, |
| 111 | + "type": string, |
| 112 | + "html": string, |
| 113 | + "height": number, |
| 114 | + "author_name": string, |
| 115 | + "width": number, |
| 116 | + "title": string, |
| 117 | + "author_url": string, |
| 118 | + "version": string, |
| 119 | + "thumbnail_height": number, |
| 120 | + "provider_url": string, |
| 121 | + "thumbnail_url": string, |
| 122 | +}; |
0 commit comments