mirror of
https://github.com/Stremio/stremio-web.git
synced 2026-03-11 21:27:05 +00:00
deep links mapped in stream
This commit is contained in:
parent
5439eabdf3
commit
65fc13ed8b
2 changed files with 45 additions and 4 deletions
|
|
@ -6,12 +6,21 @@ const { Button, Image, PlayIconCircleCentered } = require('stremio/common');
|
|||
const StreamPlaceholder = require('./StreamPlaceholder');
|
||||
const styles = require('./styles');
|
||||
|
||||
const Stream = ({ className, addonName, title, thumbnail, progress, ...props }) => {
|
||||
const Stream = ({ className, addonName, title, thumbnail, progress, deepLinks, ...props }) => {
|
||||
const href = React.useMemo(() => {
|
||||
return deepLinks ?
|
||||
typeof deepLinks.player === 'string' ?
|
||||
deepLinks.player
|
||||
:
|
||||
null
|
||||
:
|
||||
null;
|
||||
}, [deepLinks]);
|
||||
const renderThumbnailFallback = React.useMemo(() => () => (
|
||||
<Icon className={styles['placeholder-icon']} icon={'ic_broken_link'} />
|
||||
), []);
|
||||
return (
|
||||
<Button {...props} className={classnames(className, styles['stream-container'])} title={title}>
|
||||
<Button href={href} {...props} className={classnames(className, styles['stream-container'])} title={title}>
|
||||
{
|
||||
typeof thumbnail === 'string' && thumbnail.length > 0 ?
|
||||
<div className={styles['thumbnail-container']} title={addonName}>
|
||||
|
|
@ -49,6 +58,9 @@ Stream.propTypes = {
|
|||
title: PropTypes.string,
|
||||
thumbnail: PropTypes.string,
|
||||
progress: PropTypes.number,
|
||||
deepLinks: PropTypes.shape({
|
||||
player: PropTypes.string
|
||||
})
|
||||
};
|
||||
|
||||
module.exports = Stream;
|
||||
|
|
|
|||
|
|
@ -44,8 +44,37 @@ const mapMetaDetailsState = (meta_details) => {
|
|||
:
|
||||
meta_resource;
|
||||
});
|
||||
// TODO map streams with progress
|
||||
const streams_resources = meta_details.streams_resources;
|
||||
const streams_resources = meta_details.streams_resources.map((stream_resource) => {
|
||||
return stream_resource.content.type === 'Ready' ?
|
||||
{
|
||||
|
||||
request: stream_resource.request,
|
||||
content: {
|
||||
type: 'Ready',
|
||||
content: stream_resource.content.content.map((stream) => ({
|
||||
...stream,
|
||||
// TODO map progress
|
||||
deepLinks: deepLinking.withStream({
|
||||
stream,
|
||||
streamTransportUrl: stream_resource.request.base,
|
||||
// TODO metaTransportUrl should be based on state
|
||||
metaTransportUrl: meta_details.meta_resources.reduceRight((result, meta_resource) => {
|
||||
if (meta_resource.content.type === 'Ready') {
|
||||
return meta_resource.request.base;
|
||||
}
|
||||
|
||||
return result;
|
||||
}, ''),
|
||||
type: selected.meta_resource_ref.type_name,
|
||||
id: selected.meta_resource_ref.id,
|
||||
videoId: selected.streams_resource_ref.id,
|
||||
})
|
||||
}))
|
||||
}
|
||||
}
|
||||
:
|
||||
stream_resource;
|
||||
});
|
||||
return { selected, meta_resources, streams_resources };
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue