forked from native-html/plugins
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathYoutubeExample.js
More file actions
55 lines (52 loc) · 1.11 KB
/
YoutubeExample.js
File metadata and controls
55 lines (52 loc) · 1.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import React from 'react';
import RenderHTML from '@native-html/render';
import iframe, { iframeModel } from '@native-html/iframe-plugin';
import WebView from 'react-native-webview';
const htmlConfig = {
renderers: {
iframe
},
tagsStyles: {
iframe: {
alignSelf: 'center'
}
},
customHTMLElementModels: {
iframe: iframeModel
},
WebView
};
const youtubeIframe = `
<p>
<iframe width="560"
height="315"
src="https://www.youtube.com/watch?v=YWEsoSosQXQ"
frameborder="0"
allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"
allowfullscreen>
</iframe>
</p>
<p>This is a paragraph.</p>
`;
export default function YoutubeExample({
instance,
onLinkPress,
availableWidth,
scalesPageToFit = true
}) {
return (
<RenderHTML
key={`youtube-${instance}`}
contentWidth={availableWidth}
source={{ html: youtubeIframe }}
{...htmlConfig}
renderersProps={{
a: { onPress: onLinkPress },
iframe: {
scalesPageToFit
}
}}
debug={false}
/>
);
}