fix: reset time to zero on file end

This commit is contained in:
Derek Yesmunt 2019-01-29 23:15:01 -05:00
parent 33ec088006
commit 0f60b01155
2 changed files with 7 additions and 8 deletions

View file

@ -48,6 +48,7 @@ class MediaPlayer extends React.PureComponent {
claim,
onStartCb,
onFinishCb,
savePosition,
} = this.props;
const loadedMetadata = () => {
@ -95,13 +96,7 @@ class MediaPlayer extends React.PureComponent {
if (position) {
mediaElement.currentTime = position;
}
mediaElement.addEventListener('timeupdate', () =>
this.props.savePosition(
claim.claim_id,
`${claim.txid}:${claim.nout}`,
mediaElement.currentTime
)
);
mediaElement.addEventListener('timeupdate', () => savePosition(mediaElement.currentTime));
mediaElement.addEventListener('click', this.togglePlayListener);
mediaElement.addEventListener('loadedmetadata', loadedMetadata.bind(this), {
once: true,
@ -110,6 +105,7 @@ class MediaPlayer extends React.PureComponent {
if (onFinishCb) {
onFinishCb();
}
savePosition(0);
});
mediaElement.addEventListener('webkitfullscreenchange', win32FullScreenChange.bind(this));
mediaElement.addEventListener('volumechange', () => {

View file

@ -18,6 +18,7 @@ type Props = {
written_bytes: number,
download_path: string,
completed: boolean,
blobs_completed: number,
},
fileInfoErrors: ?{
[string]: boolean,
@ -259,7 +260,9 @@ class FileViewer extends React.PureComponent<Props> {
downloadCompleted={fileInfo.completed}
changeVolume={changeVolume}
volume={volume}
savePosition={savePosition}
savePosition={newPosition =>
savePosition(claim.claim_id, `${claim.txid}:${claim.nout}`, newPosition)
}
claim={claim}
uri={uri}
position={position}