This is a Feature request.
Currently video tag is not supported.. if somehow in renders we get parsed children.. we can render..
Yes.
Yes
Yes
Both.
Yes.
Yes.
Environment:
React: 16.3.1
React native: 0.55.3
react-native-render-html: 3.9.3
Video component should be rendered..
+1
HI! Ive tried to implement custom renderer with
<HTML
containerStyle={styles.content}
html={description}
renderers={{
video: ({ src }) => (
<Video
style={{ width: Dimensions.get('window').width - 30 }}
source={{ uri: src }}
/>
),
}}
/>
My workaround is to use change video tag with videos and format input html string
Yeah that would work... but still a work around... we need not have to filter it out, just ignore it and pass down its children.
1: you need to set the height of the video!
2: get rid of 'video' and 'source' in IGNORED_TAGS in file react-native-render-html/src/HTMLUtils.js
about line 44,
For render video I just remove video tag from ignoredTags list
import Video from 'react-native-video'
import HTMLView from 'react-native-render-html'
import { IGNORED_TAGS } from 'react-native-render-html/src/HTMLUtils'
<HTMLView
html={content}
renderers={{
video: ({ src }) => (
<Video source={{ uri: src }} />
),
}}
ignoredTags={IGNORED_TAGS.filter(tag => tag !== 'video')}
/>
This work around doesn't seem to be working. Anyone else have better luck?
ignoredTags={IGNORED_TAGS.filter(tag => tag !== 'video')}
Worked for me, but I used a WebView to show the video:
<HTML
onLinkPress={ (event, linkUrl) => { Linking.openURL(linkUrl); } }
ignoredTags={IGNORED_TAGS.filter(tag => tag !== 'video')}
renderers={{
iframe: (htmlAttribs, children, convertedCSSStyles, passProps) => {
return <View key={passProps.key} style={{ width: "100%", aspectRatio:16.0/9.0, marginTop:16, marginBottom:16 }}><WebView
scrollEnabled={false}
source={{ uri: htmlAttribs.src }}
style={{ flex: 1, width: "100%", aspectRatio: 16.0 / 9.0 }}
/></View>
},
video: (htmlAttribs, children, convertedCSSStyles, passProps) => {
return <View key={passProps.key} style={{ width: "100%", aspectRatio:16.0/9.0, marginTop:16, marginBottom:16 }}><WebView
scrollEnabled={false}
source={{ uri: htmlAttribs.src }}
style={{ flex: 1, width: "100%", aspectRatio: 16.0 / 9.0 }}
/></View>
}
}}
/>
It also requires that video tag contains "src" attribute! Otherwise, you could check children content to get src from source children inner tag.
Most helpful comment
Worked for me, but I used a WebView to show the video:
It also requires that video tag contains "src" attribute! Otherwise, you could check children content to get
srcfrom source children inner tag.