mirror of
https://github.com/Stremio/stremio-web.git
synced 2026-08-19 22:57:51 +00:00
show toast when subtitles track loaded
This commit is contained in:
parent
b82cd8e452
commit
8a4825e1a2
2 changed files with 16 additions and 0 deletions
|
|
@ -92,6 +92,14 @@ const Player = ({ urlParams }) => {
|
|||
});
|
||||
}
|
||||
}, []);
|
||||
const onSubtitlesTrackLoaded = React.useCallback((track) => {
|
||||
toast.show({
|
||||
type: 'success',
|
||||
title: 'Subtitles loaded',
|
||||
message: `Subtitles from ${track.origin} loaded`,
|
||||
timeout: 4000
|
||||
});
|
||||
}, []);
|
||||
const onPlayRequested = React.useCallback(() => {
|
||||
dispatch({ propName: 'paused', propValue: false });
|
||||
}, []);
|
||||
|
|
@ -317,6 +325,7 @@ const Player = ({ urlParams }) => {
|
|||
onError={onError}
|
||||
onPropValue={onPropChanged}
|
||||
onPropChanged={onPropChanged}
|
||||
onSubtitlesTrackLoaded={onSubtitlesTrackLoaded}
|
||||
onImplementationChanged={onImplementationChanged}
|
||||
/>
|
||||
{
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ const Video = React.forwardRef(({ className, ...props }, ref) => {
|
|||
const onErrorRef = useLiveRef(props.onError);
|
||||
const onPropValueRef = useLiveRef(props.onPropValue);
|
||||
const onPropChangedRef = useLiveRef(props.onPropChanged);
|
||||
const onSubtitlesTrackLoadedRef = useLiveRef(props.onSubtitlesTrackLoaded);
|
||||
const onImplementationChangedRef = useLiveRef(props.onImplementationChanged);
|
||||
const containerElementRef = React.useRef(null);
|
||||
const videoRef = React.useRef(null);
|
||||
|
|
@ -45,6 +46,11 @@ const Video = React.forwardRef(({ className, ...props }, ref) => {
|
|||
onPropChangedRef.current(propName, propValue);
|
||||
}
|
||||
});
|
||||
videoRef.current.on('subtitlesTrackLoaded', (track) => {
|
||||
if (typeof onSubtitlesTrackLoadedRef.current === 'function') {
|
||||
onSubtitlesTrackLoadedRef.current(track);
|
||||
}
|
||||
});
|
||||
if (typeof onImplementationChangedRef.current === 'function') {
|
||||
onImplementationChangedRef.current(videoRef.current.constructor.manifest);
|
||||
}
|
||||
|
|
@ -79,6 +85,7 @@ Video.propTypes = {
|
|||
onError: PropTypes.func,
|
||||
onPropValue: PropTypes.func,
|
||||
onPropChanged: PropTypes.func,
|
||||
onSubtitlesTrackLoaded: PropTypes.func,
|
||||
onImplementationChanged: PropTypes.func
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue