diff --git a/src/integration/peertube/Resources/modules/components/player.jsx b/src/integration/peertube/Resources/modules/components/player.jsx index 1590627b0fe..e9f0afe9ef7 100644 --- a/src/integration/peertube/Resources/modules/components/player.jsx +++ b/src/integration/peertube/Resources/modules/components/player.jsx @@ -19,6 +19,10 @@ const PeerTubePlayer = (props) => { let currentInfo let updater = (playbackInfo) => { + if ('playing' === playbackInfo.playbackState) { + props.onTimeUpdate(playbackInfo.position, playbackInfo.duration) + } + if (isEmpty(currentInfo) || currentInfo.playbackState !== playbackInfo.playbackState) { currentInfo = playbackInfo @@ -52,7 +56,8 @@ const PeerTubePlayer = (props) => { PeerTubePlayer.propTypes = { url: T.string.isRequired, onPlay: T.func, // get the currentTime and totalDuration as parameters - onPause: T.func // get the currentTime and totalDuration as parameters + onPause: T.func, // get the currentTime and totalDuration as parameters + onTimeUpdate: T.func // get the currentTime and totalDuration as parameters } export { diff --git a/src/integration/peertube/Resources/modules/resources/video/components/player.jsx b/src/integration/peertube/Resources/modules/resources/video/components/player.jsx index e7ad7af02c2..a8b28637043 100644 --- a/src/integration/peertube/Resources/modules/resources/video/components/player.jsx +++ b/src/integration/peertube/Resources/modules/resources/video/components/player.jsx @@ -4,20 +4,35 @@ import {PropTypes as T} from 'prop-types' import {Video as VideoTypes} from '#/integration/peertube/prop-types' import {PeerTubePlayer} from '#/integration/peertube/components/player' -const VideoPlayer = props => - { - if (props.currentUser) { - props.updateProgression(props.video.id, currentTime, duration) - } - }} - onPause={(currentTime, duration) => { - if (props.currentUser) { - props.updateProgression(props.video.id, currentTime, duration) - } - }} - /> +const VideoPlayer = props => { + let lastSaved = 0 + + return ( + { + if (props.currentUser) { + props.updateProgression(props.video.id, currentTime, duration) + } + }} + onPause={(currentTime, duration) => { + if (props.currentUser) { + props.updateProgression(props.video.id, currentTime, duration) + } + }} + onTimeUpdate={(currentTime, duration) => { + if (props.currentUser) { + const interval = Math.round((duration / 100) * 5) + const roundedTime = Math.round(currentTime) + if (roundedTime > lastSaved && 0 === roundedTime % interval) { + props.updateProgression(props.video.id, currentTime, duration) + lastSaved = roundedTime + } + } + }} + /> + ) +} VideoPlayer.propTypes = { video: T.shape( diff --git a/src/plugin/video-player/Resources/modules/files/video/components/player.jsx b/src/plugin/video-player/Resources/modules/files/video/components/player.jsx index 2fd5771740c..0cf371b0190 100644 --- a/src/plugin/video-player/Resources/modules/files/video/components/player.jsx +++ b/src/plugin/video-player/Resources/modules/files/video/components/player.jsx @@ -5,27 +5,44 @@ import {File as FileTypes} from '#/main/core/files/prop-types' // The wrapping div is required because it will throw a JS on unmount as the parent is a Fragment. // Search for "Uncaught DOMException: Node.removeChild: The node to be removed is not a child of this node" for mor information. -const VideoPlayer = props => -
- -
+const VideoPlayer = props => { + let lastSaved = 0 + + return ( +
+ +
+ ) +} + + VideoPlayer.propTypes = { mimeType: T.string.isRequired,