fix #2240: reset time to zero on file end #2246

Merged
derek-yesmunt merged 2 commits from master into master 2019-01-30 05:52:09 +01:00
2 changed files with 7 additions and 8 deletions
Showing only changes of commit 0f60b01155 - Show all commits

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}