deep links integrated in video

This commit is contained in:
nklhrstv 2020-04-06 17:28:10 +03:00
parent cf9ded23a2
commit 5439eabdf3
2 changed files with 25 additions and 5 deletions

View file

@ -6,9 +6,21 @@ const { Button, Image } = require('stremio/common');
const VideoPlaceholder = require('./VideoPlaceholder');
const styles = require('./styles');
const Video = ({ className, id, title, thumbnail, episode, released, upcoming, watched, progress, ...props }) => {
const Video = ({ className, id, title, thumbnail, episode, released, upcoming, watched, progress, deepLinks, ...props }) => {
const href = React.useMemo(() => {
return deepLinks ?
typeof deepLinks.player === 'string' ?
deepLinks.player
:
typeof deepLinks.meta_details_streams === 'string' ?
deepLinks.meta_details_streams
:
null
:
null;
}, [deepLinks]);
return (
<Button {...props} className={classnames(className, styles['video-container'])} title={title}>
<Button href={href} {...props} className={classnames(className, styles['video-container'])} title={title}>
{
typeof thumbnail === 'string' && thumbnail.length > 0 ?
<div className={styles['thumbnail-container']}>
@ -84,7 +96,11 @@ Video.propTypes = {
released: PropTypes.instanceOf(Date),
upcoming: PropTypes.bool,
watched: PropTypes.bool,
progress: PropTypes.number
progress: PropTypes.number,
deepLinks: PropTypes.shape({
meta_details_streams: PropTypes.string,
player: PropTypes.string
})
};
module.exports = Video;

View file

@ -1,5 +1,5 @@
const React = require('react');
const { useModelState } = require('stremio/common');
const { deepLinking, useModelState } = require('stremio/common');
const initMetaDetailsState = () => ({
selected: null,
@ -32,7 +32,11 @@ const mapMetaDetailsState = (meta_details) => {
NaN
),
// TODO add watched and progress
href: `#/metadetails/${meta_resource.content.content.type}/${meta_resource.content.content.id}/${video.id}`
deepLinks: deepLinking.withVideo({
video,
metaTransportUrl: meta_resource.request.base,
metaItem: meta_resource.content.content
})
}))
}
}