File tree Expand file tree Collapse file tree 2 files changed +33
-0
lines changed
Expand file tree Collapse file tree 2 files changed +33
-0
lines changed Original file line number Diff line number Diff line change @@ -98,6 +98,25 @@ const App = () => {
9898};
9999```
100100
101+ Typescript usage.
102+
103+ ``` typescript
104+ import React , {useRef } from ' react' ;
105+ import { YoutubeIframeRef } from ' react-native-youtube-iframe' ;
106+ const App = () => {
107+ const playerRef = useRef <YoutubeIframeRef >(null );
108+ return (
109+ < YoutubePlayer height = {400 } width = {400 } ref = {playerRef } videoId = {' AVAc1gYLZK0' } / >
110+ < Button
111+ title = " get current player time"
112+ onPress = {() => {
113+ playerRef ?.current ?.getCurrentTime ().then (data => console .log ({data }));
114+ }}
115+ / >
116+ );
117+ };
118+ ```
119+
101120## videoId
102121
103122** _ String_ **
Original file line number Diff line number Diff line change @@ -2,6 +2,16 @@ import React from 'react';
22import { StyleProp , ViewStyle } from 'react-native' ;
33import { WebViewProps } from 'react-native-webview' ;
44
5+ export interface YoutubeIframeRef {
6+ getDuration : ( ) => Promise < number > ;
7+ getCurrentTime : ( ) => Promise < number > ;
8+ isMuted : ( ) => Promise < boolean > ;
9+ getVolume : ( ) => Promise < number > ;
10+ getPlaybackRate : ( ) => Promise < number > ;
11+ getAvailablePlaybackRates : ( ) => Promise < number [ ] > ;
12+ seekTo : ( seconds : number , allowSeekAhead : boolean ) => void ;
13+ }
14+
515export interface InitialPlayerParams {
616 loop ?: boolean ;
717 controls ?: boolean ;
@@ -104,6 +114,10 @@ export interface YoutubeIframeProps {
104114 * Flag to decide whether or not a user can zoom the video webview.
105115 */
106116 allowWebViewZoom ?: Boolean ;
117+ /**
118+ * Set this React Ref to use ref functions such as getDuration.
119+ */
120+ ref ?: React . MutableRefObject < YoutubeIframeRef | null > ;
107121}
108122
109123declare const YoutubeIframe : React . SFC < YoutubeIframeProps > ;
You can’t perform that action at this time.
0 commit comments