Skip to content

Commit

Permalink
fix loading state and don't overwrite onEnd
Browse files Browse the repository at this point in the history
  • Loading branch information
LunatiqueCoder committed Mar 16, 2022
1 parent 1f17cc6 commit e387aa9
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/VideoPlayer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ export const VideoPlayer = (props: VideoPlayerProps) => {
const [seekerOffset, setSeekerOffset] = useState(0);
const [seekerWidth, setSeekerWidth] = useState(0);
const [seeking, setSeeking] = useState(false);
const [loading, setLoading] = useState(false);
const [loading, setLoading] = useState(true);
const [currentTime, setCurrentTime] = useState(0);
const [error, setError] = useState(false);
const [duration, setDuration] = useState(0);
Expand Down Expand Up @@ -124,6 +124,9 @@ export const VideoPlayer = (props: VideoPlayerProps) => {
setCurrentTime(duration);
setPaused(true);
}
if (typeof onEnd === 'function') {
onEnd();
}
};

const _onError = () => {
Expand Down Expand Up @@ -186,7 +189,7 @@ export const VideoPlayer = (props: VideoPlayerProps) => {
const events = {
onError: onError || _onError,
onBack: (onBack || _onBack(navigator)) as () => void,
onEnd: onEnd || _onEnd,
onEnd: _onEnd,
onScreenTouch: _onScreenTouch,
onEnterFullscreen,
onExitFullscreen,
Expand Down

0 comments on commit e387aa9

Please sign in to comment.