Skip to content
Snippets Groups Projects
Select Git revision
  • 0ce9b7821e0d3f2ac0fc0b733ce743c831727df9
  • mui5-annotation-on-video-stable default
  • get_setter_canvasSizeInformations
  • fix-error-div-into-p
  • annotation-on-video-v2
  • detached
  • annotation-on-video-r17
  • mui5
  • mui5-react-18
  • jacob-test
  • annotation-on-video protected
  • master
  • test-antoinev1
  • 20-fetch-thumbnail-on-annotation
  • add-research-field
  • Save
  • add-plugin
  • 14-wip-no-seek-to
  • 14-bug-on-video-time-control
  • 9_wip_videotests
  • _upgrade_material_ui
  • latest-tetras-16
  • v3.3.0
  • v3.2.0
  • v3.1.1
  • v3.1.0
  • v3.0.0
  • v3.0.0-rc.7
  • v3.0.0-rc.6
  • v3.0.0-rc.5
  • v3.0.0-rc.4
  • v3.0.0-rc.3
  • v3.0.0-rc.2
  • v3.0.0-rc.1
  • v3.0.0-beta.10
  • v3.0.0-beta.9
  • v3.0.0-beta.8
  • v3.0.0-beta.7
  • v3.0.0-beta.6
  • v3.0.0-beta.5
  • v3.0.0-beta.3
41 results

AnnotationsOverlayVideo.js

Blame
  • AnnotationsOverlayVideo.js 20.42 KiB
    import React, { Component } from 'react';
    import PropTypes from 'prop-types';
    import isEqual from 'lodash/isEqual';
    import debounce from 'lodash/debounce';
    import flatten from 'lodash/flatten';
    import sortBy from 'lodash/sortBy';
    import xor from 'lodash/xor';
    import ResizeObserver from 'react-resize-observer';
    import CircularProgress from '@material-ui/core/CircularProgress';
    import CanvasOverlayVideo from '../lib/CanvasOverlayVideo';
    import CanvasWorld from '../lib/CanvasWorld';
    import CanvasAnnotationDisplay from '../lib/CanvasAnnotationDisplay';
    
    /** AnnotationsOverlayVideo - based on AnnotationsOverlay */
    export class AnnotationsOverlayVideo extends Component {
      /**
       * annotationsMatch - compares previous annotations to current to determine
       * whether to add a new updateCanvas method to draw annotations
       * @param  {Array} currentAnnotations
       * @param  {Array} prevAnnotations
       * @return {Boolean}
       */
      static annotationsMatch(currentAnnotations, prevAnnotations) {
        if (!currentAnnotations && !prevAnnotations) return true;
        if (
          (currentAnnotations && !prevAnnotations)
          || (!currentAnnotations && prevAnnotations)
        ) return false;
    
        if (currentAnnotations.length === 0 && prevAnnotations.length === 0) return true;
        if (currentAnnotations.length !== prevAnnotations.length) return false;
        return currentAnnotations.every((annotation, index) => {
          const newIds = annotation.resources.map(r => r.id);
          const prevIds = prevAnnotations[index].resources.map(r => r.id);
          if (newIds.length === 0 && prevIds.length === 0) return true;
          if (newIds.length !== prevIds.length) return false;
    
          if ((annotation.id === prevAnnotations[index].id) && (isEqual(newIds, prevIds))) {
            return true;
          }
          return false;
        });
      }
    
      /** @private */
      static isAnnotaionInTemporalSegment(resource, time) {
        const temporalfragment = resource.temporalfragmentSelector;
        if (temporalfragment && temporalfragment.length > 0) {
          const start = temporalfragment[0] || 0;
          const end = (temporalfragment.length > 1) ? temporalfragment[1] : Number.MAX_VALUE;
          if (start <= time && time < end) {
            //
          } else {
            return false;
          }
        }
        return true;
      }
    
      /**
       * @param {Object} props
       */
      constructor(props) {
        super(props);
    
        this.ref = React.createRef();
        this.canvasOverlay = null;
        // An initial value for the updateCanvas method
        this.updateCanvas = () => {};
        this.onCanvasClick = this.onCanvasClick.bind(this);