diff --git a/src/routes/Player/Player.js b/src/routes/Player/Player.js index 9e685a95a..631964691 100644 --- a/src/routes/Player/Player.js +++ b/src/routes/Player/Player.js @@ -25,7 +25,7 @@ const Player = ({ urlParams, queryParams }) => { queryParams.has('maxAudioChannels') ? parseInt(queryParams.get('maxAudioChannels'), 10) : null ]; }, [queryParams]); - const [player, timeUpdate, pushToLibrary] = usePlayer(urlParams); + const [player, timeUpdate, pushToLibrary, ended] = usePlayer(urlParams); const [settings, updateSettings] = useSettings(); const streamingServer = useStreamingServer(); const routeFocused = useRouteFocused(); @@ -95,6 +95,7 @@ const Player = ({ urlParams, queryParams }) => { setVideoState({ [propName]: propValue }); }, []); const onEnded = React.useCallback(() => { + ended(); pushToLibrary(); if (player.nextVideo !== null) { window.location.replace( diff --git a/src/routes/Player/usePlayer.js b/src/routes/Player/usePlayer.js index 503562c5f..e0e735bd8 100644 --- a/src/routes/Player/usePlayer.js +++ b/src/routes/Player/usePlayer.js @@ -103,8 +103,16 @@ const usePlayer = (urlParams) => { } }, 'player'); }, []); + const ended = React.useCallback(() => { + core.transport.dispatch({ + action: 'Player', + args: { + action: 'Ended' + } + }, 'player'); + }, []); const player = useModelState({ model: 'player', action, map }); - return [player, timeUpdate, pushToLibrary]; + return [player, timeUpdate, pushToLibrary, ended]; }; module.exports = usePlayer;