Skip to content

Commit

Permalink
Merge pull request #6 from SCENE-CE/4-fix-origin-on-video3
Browse files Browse the repository at this point in the history
4 fix origin on video3
  • Loading branch information
geourjoa authored Nov 13, 2024
2 parents 91a3747 + 4991ae3 commit 8151f95
Show file tree
Hide file tree
Showing 5 changed files with 124 additions and 43 deletions.
13 changes: 6 additions & 7 deletions __tests__/integration/mirador/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta name="theme-color" content="#000000">
<title>Mirador</title>
<title>Mirador Video</title>
</head>
<body>
<div id="mirador" style="position: absolute; top: 0; bottom: 0; left: 0; right: 0;"></div>
Expand All @@ -16,14 +16,13 @@
transitions: window.location.port === '4488' ? { create: () => 'none' } : {},
},
catalog: [
{ manifestId: 'https://iiif.bodleian.ox.ac.uk/iiif/manifest/e32a277e-91e2-4a6d-8ba6-cc4bad230410.json' },
{ manifestId: 'https://iiif.harvardartmuseums.org/manifests/object/299843' },
/* { manifestId: 'https://iiif.bodleian.ox.ac.uk/iiif/manifest/e32a277e-91e2-4a6d-8ba6-cc4bad230410.json' },
{ manifestId: 'https://iiif.harvardartmuseums.org/manifests/object/299843' },*/
{ manifestId: "https://files.tetras-libre.fr/dev/vertical_video_with_annot.json"},
{ manifestId: "https://files.tetras-libre.fr/dev/cats_video_with_annot.json"},
{ manifestId: "https://files.tetras-libre.fr/dev/test-vertical-video-800H.json"},
{ manifestId: "https://files.tetras-libre.fr/dev/Heterogeneous-media-on-several-canvases.json"},
{ manifestId: "https://files.tetras-libre.fr/dev/vertical_video_with_annot.json"},


{ manifestId: "https://dzkimgs.l.u-tokyo.ac.jp/videos/cat2020/manifest.json"},
{ manifestId: "https://files.tetras-libre.fr/dev/vertical_video_with_annot.json"}
]
});
</script>
Expand Down
19 changes: 18 additions & 1 deletion src/components/AnnotationsOverlayVideo.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import CanvasOverlayVideo from '../lib/CanvasOverlayVideo';
import CanvasWorld from '../lib/CanvasWorld';
import CanvasAnnotationDisplay from '../lib/CanvasAnnotationDisplay';
import { VideosReferences } from '../plugins/VideosReferences';
import {ORIENTATIONS} from './VideoViewer';

Check failure on line 14 in src/components/AnnotationsOverlayVideo.js

View workflow job for this annotation

GitHub Actions / build (18.x)

Dependency cycle via ../containers/AnnotationsOverlayVideo:6

Check failure on line 14 in src/components/AnnotationsOverlayVideo.js

View workflow job for this annotation

GitHub Actions / build (18.x)

A space is required after '{'

Check failure on line 14 in src/components/AnnotationsOverlayVideo.js

View workflow job for this annotation

GitHub Actions / build (18.x)

A space is required before '}'

Check failure on line 14 in src/components/AnnotationsOverlayVideo.js

View workflow job for this annotation

GitHub Actions / build (20.x)

Dependency cycle via ../containers/AnnotationsOverlayVideo:6

Check failure on line 14 in src/components/AnnotationsOverlayVideo.js

View workflow job for this annotation

GitHub Actions / build (20.x)

A space is required after '{'

Check failure on line 14 in src/components/AnnotationsOverlayVideo.js

View workflow job for this annotation

GitHub Actions / build (20.x)

A space is required before '}'

/** AnnotationsOverlayVideo - based on AnnotationsOverlay */
export class AnnotationsOverlayVideo extends Component {
Expand Down Expand Up @@ -83,6 +84,8 @@ export class AnnotationsOverlayVideo extends Component {
this.imagesLoading = [];
this.imagesReady = [];

this.currentOrientation = props.currentOrientation;

const { videoTarget: temporalfragment } = this.props;
if (temporalfragment && temporalfragment.length > 0) {
this.temporalOffset = temporalfragment[0] || 0;
Expand Down Expand Up @@ -618,15 +621,28 @@ export class AnnotationsOverlayVideo extends Component {
}
}


Check failure on line 624 in src/components/AnnotationsOverlayVideo.js

View workflow job for this annotation

GitHub Actions / build (18.x)

More than 1 blank line not allowed

Check failure on line 624 in src/components/AnnotationsOverlayVideo.js

View workflow job for this annotation

GitHub Actions / build (20.x)

More than 1 blank line not allowed
/**
* Renders things
*/
render() {
const { showProgress } = this.state;
const debugPositionning = false;
const circularProgress = (<CircularProgress style={{ left: '50%', position: 'absolute', top: '50%' }} />);
return (
<>
<canvas ref={this.ref} style={{ left: 0, position: 'absolute', top: 0 }} />
<canvas
ref={this.ref}
style={{
left: 0,
position: 'relative',
top: 0,
border: debugPositionning ? '6px solid yellow' : 'none',

Check failure on line 640 in src/components/AnnotationsOverlayVideo.js

View workflow job for this annotation

GitHub Actions / build (18.x)

Expected object keys to be in insensitive ascending order. 'border' should be before 'top'

Check failure on line 640 in src/components/AnnotationsOverlayVideo.js

View workflow job for this annotation

GitHub Actions / build (20.x)

Expected object keys to be in insensitive ascending order. 'border' should be before 'top'
width: (this.currentOrientation === ORIENTATIONS.LANDSCAPE ? '100%' : 'auto'),

// transform: "translate(50%)",
}}
/>
<ResizeObserver onResize={this.onCanvasResize} />
{ showProgress && circularProgress }
</>
Expand Down Expand Up @@ -659,6 +675,7 @@ AnnotationsOverlayVideo.propTypes = {
annotations: PropTypes.arrayOf(PropTypes.object), // eslint-disable-line react/forbid-prop-types
canvas: PropTypes.object, // eslint-disable-line react/forbid-prop-types
canvasWorld: PropTypes.instanceOf(CanvasWorld).isRequired,
currentOrientation: PropTypes.string,
currentTime: PropTypes.number,
deselectAnnotation: PropTypes.func,
drawAnnotations: PropTypes.bool,
Expand Down
128 changes: 94 additions & 34 deletions src/components/VideoViewer.js
Original file line number Diff line number Diff line change
@@ -1,29 +1,15 @@
import flatten from 'lodash/flatten';
import flattenDeep from 'lodash/flattenDeep';
import { createRef, Component } from 'react';
import React, { createRef, Component } from 'react';

Check warning on line 3 in src/components/VideoViewer.js

View workflow job for this annotation

GitHub Actions / build (18.x)

'React' is defined but never used

Check warning on line 3 in src/components/VideoViewer.js

View workflow job for this annotation

GitHub Actions / build (20.x)

'React' is defined but never used
import PropTypes from 'prop-types';
import { styled } from '@mui/material/styles';
import AnnotationItem from '../lib/AnnotationItem';
import AnnotationsOverlayVideo from '../containers/AnnotationsOverlayVideo';

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

View workflow job for this annotation

GitHub Actions / build (18.x)

Dependency cycle via ../components/AnnotationsOverlayVideo:6

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

View workflow job for this annotation

GitHub Actions / build (20.x)

Dependency cycle via ../components/AnnotationsOverlayVideo:6
import WindowCanvasNavigationControlsVideo from '../containers/WindowCanvasNavigationControlsVideo';

const StyledContainer = styled('div')(() => ({
alignItems: 'center',
display: 'flex',
width: '100%',
justifyContent:'center'
}));

const StyledFlexFill = styled('div')(() => ({
height: '100%',
position: 'relative',
display: 'flex',
justifyContent:'center'
}));

const StyledVideo = styled('video')(() => ({
maxHeight: '100%',
}));
export const ORIENTATIONS = {
LANDSCAPE: 'landscape',
PORTRAIT: 'portrait',
};

/** */
export class VideoViewer extends Component {
Expand Down Expand Up @@ -121,6 +107,8 @@ export class VideoViewer extends Component {
this.setState({ time: 0 });
}


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

View workflow job for this annotation

GitHub Actions / build (18.x)

More than 1 blank line not allowed

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

View workflow job for this annotation

GitHub Actions / build (20.x)

More than 1 blank line not allowed

/* eslint-disable jsx-a11y/media-has-caption */
/** */
render() {
Expand Down Expand Up @@ -158,23 +146,92 @@ export class VideoViewer extends Component {
? videoResources[len - 1].body[0] : null;
const videoTargetTemporalfragment = len > 0
? videoResources[len - 1].temporalfragment : [];

let currentOrientation;

if (video) {
console.log('video', video);
currentOrientation = video.getWidth() > video.getHeight() ? ORIENTATIONS.LANDSCAPE : ORIENTATIONS.PORTRAIT;
}

const debugPositionning = false;

return (
<StyledContainer>
<StyledFlexFill>
{ video && (
<>
<StyledVideo key={video.id} ref={this.videoRef} {...videoOptions}>
<div
className="outerContainer"
style={{
border: debugPositionning ? '6px solid blue' : 'none',
width: '100%',
height: '100%',

Check failure on line 165 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. 'height' should be before 'width'

Check failure on line 165 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. 'height' should be before 'width'
display: 'flex',

Check failure on line 166 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. 'display' should be before 'height'

Check failure on line 166 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. 'display' should be before 'height'
justifyContent: 'center',
position: 'relative',
}}
>
{video && (
<>
<div style={{
border: debugPositionning ? '6px solid red' : 'none',
position: 'relative',
width: '100%',
display: 'flex',

Check failure on line 177 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. 'display' should be before 'width'

Check failure on line 177 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. 'display' should be before 'width'
alignItems: 'center',
marginBottom: '122px', // TODO Space for navigation controls
flexDirection: 'column',
// flexDirection: currentOrientation === ORIENTATIONS.LANDSCAPE ? 'row' : 'column',
backgroundColor: 'black',
}}
>
<div style={{
border: debugPositionning ? '6px solid green' : 'none',
width: 'fit-content',
maxWidth: '100%',
}}
>
<video
style={{
border: debugPositionning ? '6px solid pink' : 'none',
top: 0,
position: 'absolute', // 'absolute' or 'block
width: (currentOrientation === ORIENTATIONS.LANDSCAPE ? '100%' : 'auto'),
height: (currentOrientation === ORIENTATIONS.PORTRAIT ? '100%' : 'auto'),
maxWidth: '100%',

}}
key={video.id}
ref={this.videoRef}
{...videoOptions}
>
{' '}
{/* pink border */}
<source src={video.id} type={video.getFormat()} />
{ vttContent.map(vttc => (<track key={vttc.id} src={vttc.id} srcLang={vttc.language} />)) }
</StyledVideo>
<AnnotationsOverlayVideo windowId={windowId} videoRef={this.videoRef} videoTarget={videoTargetTemporalfragment} key={`${windowId} ${video.id}`} />
</>
)}
{vttContent.map(vttc => (
<track key={vttc.id} src={vttc.id} srcLang={vttc.language} />))}
</video>

<AnnotationsOverlayVideo
windowId={windowId}
videoRef={this.videoRef}
videoTarget={videoTargetTemporalfragment}
key={`${windowId} ${video.id}`}
currentOrientation={currentOrientation}
highlightAllAnnotations
style={{
height: '100%',
width: '100%',
objectFit: 'contain',
border: debugPositionning ? '6px solid yellow' : 'none',
}}
/>
</div>
</div>
<WindowCanvasNavigationControlsVideo windowId={windowId} />
</StyledFlexFill>
</StyledContainer>
</>
)}
</div>
);
}

/* eslint-enable jsx-a11y/media-has-caption */
}

Expand All @@ -201,9 +258,12 @@ VideoViewer.defaultProps = {
currentTime: 0,
muted: false,
paused: true,
setCurrentTime: () => {},
setHasTextTrack: () => {},
setPaused: () => {},
setCurrentTime: () => {
},
setHasTextTrack: () => {
},
setPaused: () => {
},
textTrackDisabled: true,
videoOptions: {},
};
5 changes: 5 additions & 0 deletions src/lib/CanvasAnnotationDisplay.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ export default class CanvasAnnotationDisplay {
this.hovered = hovered;
this.imageSource = imageSource;
this.canvasSize = canvasSize;

this.palette.selected.strokeStyle = 'red'; // TODO remove when finished
}

/** */
Expand Down Expand Up @@ -44,6 +46,9 @@ export default class CanvasAnnotationDisplay {
currentPalette = this.palette.default;
}

console.log('currentPalette', currentPalette);


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

[...this.svgPaths].forEach((element) => {
Expand Down
2 changes: 1 addition & 1 deletion webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ module.exports = (env, options) => {
...config,
devServer: {
hot: true,
port: 4444,
port: 4445,
static: [
'./__tests__/integration/mirador',
'./__tests__/fixtures',
Expand Down

0 comments on commit 8151f95

Please sign in to comment.