Skip to content

Commit

Permalink
Merge pull request #16 from SCENE-CE/9-fix-video-control
Browse files Browse the repository at this point in the history
Fix video control
  • Loading branch information
geourjoa authored Dec 18, 2024
2 parents c6ccf03 + f5fdd0b commit bcee841
Show file tree
Hide file tree
Showing 5 changed files with 91 additions and 94 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

170 changes: 83 additions & 87 deletions src/components/VideoViewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ export class VideoViewer extends Component {
containerRatio: 1,
handleVideoEventFunctions: {
onPlay: () => {
console.log('onPlay');
},
},
start: 0,
Expand All @@ -37,30 +36,27 @@ export class VideoViewer extends Component {

/** */
componentDidUpdate(prevProps) {
console.log('componentDidUpdate in VideoViewer.js');
const {
canvas, currentTime, paused,
setCurrentTime, setPaused,
canvas, currentTime, paused, setCurrentTime, setPaused,
} = this.props;

if (paused !== prevProps.paused) {
if (currentTime === 0) {
this.timerReset();
}
if (paused) {
this.timerStop();
} else {
this.timerStart();
}
}
// Ensure `currentTime` updates are consistent
if (currentTime !== prevProps.currentTime) {
const duration = canvas.getDuration();
if (duration && duration < currentTime) {
if (!paused) {
setPaused(true);
setCurrentTime(0);
this.timerReset();
}
//Fix issue where reactPlayer didn't populate seek to time when the time was at 0

Check failure on line 52 in src/components/VideoViewer.js

View workflow job for this annotation

GitHub Actions / build (18.x)

Expected exception block, space or tab after '//' in comment

Check failure on line 52 in src/components/VideoViewer.js

View workflow job for this annotation

GitHub Actions / build (20.x)

Expected exception block, space or tab after '//' in comment

Check failure on line 52 in src/components/VideoViewer.js

View workflow job for this annotation

GitHub Actions / build (22.x)

Expected exception block, space or tab after '//' in comment
if (prevProps.currentTime === 0 || paused === true) {
this.playerRef.current.seekTo(currentTime);
}
if (duration && currentTime > duration) {
setPaused(true);
setCurrentTime(0);
this.timerReset();
}
}
}
Expand Down Expand Up @@ -176,84 +172,84 @@ export class VideoViewer extends Component {
}}
>
{video && (
<>
<div style={{
alignItems: 'center',
backgroundColor: 'black',
border: debug ? '6px solid red' : 'none',
display: 'flex',
flexDirection: 'column',
justifyContent: 'center',
marginBottom: '122px', // TODO Space for navigation controls
position: 'relative',
width: '100%',
}}
>
<ResizeObserver onResize={this.setContainerRatio} />
<>
<div style={{
aspectRatio: playerStyle.aspectRatio,
border: debug ? '6px solid green' : 'none',
height: playerStyle.height,
maxHeight: '100%',
maxWidth: '100%',
width: playerStyle.width,
alignItems: 'center',
backgroundColor: 'black',
border: debug ? '6px solid red' : 'none',
display: 'flex',
flexDirection: 'column',
justifyContent: 'center',
marginBottom: '122px', // TODO Space for navigation controls
position: 'relative',
width: '100%',
}}
>
<ReactPlayer
width={videoStyle.width}
height={videoStyle.height}
ref={this.playerRef}
url={video.id}
controls={false} // Hide default controls
pip={false}
playbackRate={1}
playing={!paused}
muted={muted}
loop={false}
config={{
peertube: {
controls: 0,
mode: 'p2p-media-loader',
},
youtube: {
controls: 0,
modestbranding: 0,
},
}}
iiifVideoInfos={video}
style={{
aspectRatio: `${videoAspectRatio}`,
border: debug ? '6px solid pink' : 'none', // 'absolute' or 'block
height: (containerRatio < videoAspectRatio ? 'auto' : '100%'),
maxHeight: '100%',
maxWidth: '100%',
position: 'absolute',
width: (containerRatio < videoAspectRatio ? '100%' : 'auto'),
}}
onPlay={handleVideoEventFunctions.onPlay}
/>
{this.playerRef.current && (
<AnnotationsOverlayVideo
onFunctionsReady={this.handleVideoEventFunctions}
windowId={windowId}
playerRef={this.playerRef.current}
videoRef={this.playerRef.current.getInternalPlayer()}
videoTarget={videoTargetTemporalfragment}
key={`${windowId} ${video.id}`}
highlightAllAnnotations
style={{
border: debug ? '6px solid yellow' : 'none',
height: '100%',
objectFit: 'contain',
width: '100%',
}}
/>
)}
<ResizeObserver onResize={this.setContainerRatio} />
<div style={{
aspectRatio: playerStyle.aspectRatio,
border: debug ? '6px solid green' : 'none',
height: playerStyle.height,
maxHeight: '100%',
maxWidth: '100%',
width: playerStyle.width,
position: 'relative',

Check failure on line 196 in src/components/VideoViewer.js

View workflow job for this annotation

GitHub Actions / build (18.x)

Expected object keys to be in insensitive ascending order. 'position' should be before 'width'

Check failure on line 196 in src/components/VideoViewer.js

View workflow job for this annotation

GitHub Actions / build (20.x)

Expected object keys to be in insensitive ascending order. 'position' should be before 'width'

Check failure on line 196 in src/components/VideoViewer.js

View workflow job for this annotation

GitHub Actions / build (22.x)

Expected object keys to be in insensitive ascending order. 'position' should be before 'width'
}}
>
<ReactPlayer
width={videoStyle.width}
height={videoStyle.height}
ref={this.playerRef}
url={video.id}
controls={false} // Hide default controls
pip={false}
playbackRate={1}
playing={!paused}
muted={muted}
loop={false}
config={{
peertube: {
controls: 0,
mode: 'p2p-media-loader',
},
youtube: {
controls: 0,
modestbranding: 0,
},
}}
iiifVideoInfos={video}
style={{
aspectRatio: `${videoAspectRatio}`,
border: debug ? '6px solid pink' : 'none', // 'absolute' or 'block
height: (containerRatio < videoAspectRatio ? 'auto' : '100%'),
maxHeight: '100%',
maxWidth: '100%',
position: 'absolute',
width: (containerRatio < videoAspectRatio ? '100%' : 'auto'),
}}
onPlay={handleVideoEventFunctions.onPlay}
/>
{this.playerRef.current && (
<AnnotationsOverlayVideo
onFunctionsReady={this.handleVideoEventFunctions}
windowId={windowId}
playerRef={this.playerRef.current}
videoRef={this.playerRef.current.getInternalPlayer()}
videoTarget={videoTargetTemporalfragment}
key={`${windowId} ${video.id}`}
highlightAllAnnotations
style={{
border: debug ? '6px solid yellow' : 'none',
height: '100%',
objectFit: 'contain',
width: '100%',
}}
/>
)}
</div>
</div>
</div>
<WindowCanvasNavigationControlsVideo windowId={windowId} />
</>
<WindowCanvasNavigationControlsVideo windowId={windowId} playerRef={this.playerRef} />
</>
)}
</div>
);
Expand Down
8 changes: 6 additions & 2 deletions src/components/ViewerNavigationVideo.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,13 @@ export class ViewerNavigationVideo extends Component {

/** */
handleChange = (event, newValue) => {
const { paused, setCurrentTime, setSeekTo } = this.props;
const {
paused, setCurrentTime, setSeekTo, setPaused,
} = this.props;
if (!paused) {
setPaused(true);
setSeekTo(newValue);
setCurrentTime(newValue);
} else {
setCurrentTime(newValue);
}
Expand All @@ -59,7 +63,7 @@ export class ViewerNavigationVideo extends Component {
setTextTrackDisabled,
textTrackDisabled,
} = this.props;

console.log('currentTime', currentTime);
const start = (duration > 3600 || duration === undefined) ? 11 : 14;
const len = (duration > 3600 || duration === undefined) ? 8 : 5;
let durationLabel = new Date(currentTime * 1000).toISOString().substr(start, len);
Expand Down
1 change: 0 additions & 1 deletion src/components/WindowSideBarAnnotationsPanel.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ export function WindowSideBarAnnotationsPanel({
const containerRef = useRef();

useEffect(() => {
console.log(`Use effect current ${containerRef.current}`);
});

return (
Expand Down
2 changes: 0 additions & 2 deletions src/lib/CanvasAnnotationDisplay.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,6 @@ export default class CanvasAnnotationDisplay {
currentPalette = this.palette.default;
}

console.log('currentPalette', currentPalette);

if (currentPalette.globalAlpha === 0) return;

[...this.svgPaths].forEach((element) => {
Expand Down

0 comments on commit bcee841

Please sign in to comment.