Adds support for hsl videos

This commit is contained in:
Adolfo Reyna
2022-12-11 23:02:55 -05:00
parent 90be0f05bb
commit 4b54df4408
3 changed files with 32 additions and 12 deletions

View File

@@ -9,11 +9,19 @@ const videoIdF = (content) => {
let vimeoTag = content.match(/@vimeo:[0-9]+/);
let youtubeTag = content.match(/@youtube:[0-z]+/);
if (!vimeoTag && !youtubeTag) return [];
let tag = youtubeTag || vimeoTag;
let tag = youtubeTag || vimeoTag || hslTag;
tag = tag[0].substring(1);
return tag.split(':');
};
const hlsIdF = (content) => {
let hslTag = content.match(/@hls:.+\w/);
if (!hslTag) return '';
let tag = hslTag;
tag = tag[0].substring(5);
return tag;
};
const imagesTagF = (content) => {
let images = content.match(/@image:[0-z|/|.|]+/g);
if (!images) return [];
@@ -40,6 +48,7 @@ let Media = (props) => {
const imagesTag = imagesTagF(props.content);
const imageStyle = imagesTag.length == 1 ? styles.image : styles.multipleImage;
const videosId = videoIdF(props.content);
const hlsUrl = hlsIdF(props.content);
const iframeSrc = iframeTagF(props.content) || [];
const [videosFiles, setVideosFiles] = useState([]);
const [poster, setPoster] = useState('');
@@ -68,6 +77,7 @@ let Media = (props) => {
)
) :
(videosId.length ? <VimeoPlayer videoId={videosId[1]} /> : <></>);
const video2 = hlsUrl ? <VideoPlayer videoUrl={hlsUrl} postId={props.postId} /> : <></>;
const iframe = iframeSrc.length ?
<WebView
style={styles.iframe}
@@ -99,6 +109,7 @@ let Media = (props) => {
</View>
}
{video}
{video2}
{iframe}
</View>
);