Skip to content
Snippets Groups Projects
Select Git revision
  • 1d84b116005e2bbab8e219f38ad88459278e7aa9
  • demo_ci_gitlab_pages default
  • demo_gitlab_ci
  • 5-images-in-annotations
  • 5-final-images
  • 5-chpk-images-in-annot
  • tetras-main protected
  • 5-rebase-images-in-annot
  • 5-wip-images-in-annot
  • tmp
  • 1-edit-annotations-on-videos
  • 5-old-images-in-annotations
  • old_demo_ci_gitlab_pages
  • images_annotations
  • wip
  • devsetup
  • wip-annot-video-ui
  • wip-annotations-on-videos
  • master
  • v0.4.0_react16
  • wip-debugging-annotations
21 results

AnnotationDrawing.js

Blame
  • Forked from IIIF / Mirador / Mirador annotations
    Source project has a limited visibility.
    • Loïs Poujade's avatar
      ecf8aea1
      Allow to add annotations on video · ecf8aea1
      Loïs Poujade authored
      - if no Openseadragon instance, use a VideoViewerReference (based on
        OSDReferences) to get canvas size & DOM element
      - add 2 number fields to specify annotation start/end
      - speed up build by removing umd (not used in our dev setup) and demo build
      - remove conflicting dependencies
        Both removed dependencies are installed at a lower version by another
        dependence (immutable is installed by draft-js-*)
      Verified
      ecf8aea1
      History
      Allow to add annotations on video
      Loïs Poujade authored
      - if no Openseadragon instance, use a VideoViewerReference (based on
        OSDReferences) to get canvas size & DOM element
      - add 2 number fields to specify annotation start/end
      - speed up build by removing umd (not used in our dev setup) and demo build
      - remove conflicting dependencies
        Both removed dependencies are installed at a lower version by another
        dependence (immutable is installed by draft-js-*)
    VideoViewer.test.js 3.75 KiB
    import React from 'react';
    import { shallow } from 'enzyme';
    import { Utils } from 'manifesto.js';
    import AnnotationFactory from '../../../src/lib/AnnotationFactory';
    import { VideoViewer } from '../../../src/components/VideoViewer';
    import videoSimple from '../../fixtures/version-3/video.json';
    import videoCaptions from '../../fixtures/version-3/video_captions.json';
    import videoMultiCaptions from '../../fixtures/version-3/video_multiples_captions.json';
    import videoMultiCaptionsMultiAnno from '../../fixtures/version-3/video_captions_other.json';
    
    /** create wrapper */
    function createWrapper(props, suspenseFallback) {
      return shallow(
        <VideoViewer
          classes={{}}
          videoOptions={{ crossOrigin: 'anonymous' }}
          {...props}
        />,
      );
    }
    
    describe('VideoViewer', () => {
      let wrapper;
      describe('render', () => {
        it('video', () => {
          wrapper = createWrapper({
            canvas: Utils.parseManifest(videoSimple).getSequences()[0].getCanvases()[0],
          }, true);
          expect(wrapper.exists('video[crossOrigin="anonymous"]')).toBe(true); // eslint-disable-line jsx-a11y/media-has-caption
          expect(wrapper.contains(<source src="https://fixtures.iiif.io/video/indiana/30-minute-clock/medium/30-minute-clock.mp4" type="video/mp4" />)).toBe(true);
        });
        it('one caption', () => {
          const canvas = Utils.parseManifest(videoCaptions).getSequences()[0].getCanvases()[0];
          /* cf selectors/annotations/getPresentAnnotationsCanvas */
          const annotations = canvas.__jsonld.annotations.flatMap((a) => AnnotationFactory.determineAnnotation(a));
          wrapper = createWrapper({
            annotations,
            canvas,
          }, true);
          expect(wrapper.contains(<track src="https://fixtures.iiif.io/video/indiana/lunchroom_manners/lunchroom_manners.vtt" srcLang="en" />)).toBe(true);
          expect(wrapper.exists('video[crossOrigin="anonymous"]')).toBe(true); // eslint-disable-line jsx-a11y/media-has-caption
        });
        it('multiples captions', () => {
          const canvas = Utils.parseManifest(videoMultiCaptions).getSequences()[0].getCanvases()[0];
          /* cf selectors/annotations/getPresentAnnotationsCanvas */
          const annotations = canvas.__jsonld.annotations.flatMap((a) => AnnotationFactory.determineAnnotation(a));
          wrapper = createWrapper({
            annotations,
            canvas,
          }, true);
          expect(wrapper.contains(<track src="https://fixtures.iiif.io/video/indiana/lunchroom_manners/lunchroom_manners.vtt#en" srcLang="en" />)).toBe(true);
          expect(wrapper.contains(<track src="https://fixtures.iiif.io/video/indiana/lunchroom_manners/lunchroom_manners.vtt#fr" srcLang="fr" />)).toBe(true);
          expect(wrapper.exists('video[crossOrigin="anonymous"]')).toBe(true); // eslint-disable-line jsx-a11y/media-has-caption
        });
        it('multiples captions in multiples annotations', () => {
          const canvas = Utils.parseManifest(videoMultiCaptionsMultiAnno).getSequences()[0].getCanvases()[0];
          /* cf selectors/annotations/getPresentAnnotationsCanvas */
          const annotations = canvas.__jsonld.annotations.flatMap((a) => AnnotationFactory.determineAnnotation(a));
          wrapper = createWrapper({
            annotations,
            canvas,
          }, true);
          expect(wrapper.contains(<track src="https://fixtures.iiif.io/video/indiana/lunchroom_manners/lunchroom_manners.vtt#en" srcLang="en" />)).toBe(true);
          expect(wrapper.contains(<track src="https://fixtures.iiif.io/video/indiana/lunchroom_manners/lunchroom_manners.vtt#fr" srcLang="fr" />)).toBe(true);
          expect(wrapper.contains(<track src="https://fixtures.iiif.io/video/indiana/lunchroom_manners/lunchroom_manners.vtt#ru" srcLang="ru" />)).toBe(true);
          expect(wrapper.exists('video[crossOrigin="anonymous"]')).toBe(true); // eslint-disable-line jsx-a11y/media-has-caption
        });
      });
    });