summaryrefslogtreecommitdiff
path: root/animism-align/frontend/app/views/viewer/player/components.inline/inline.video.js
blob: cf3043baf9884e1396f38777696d99e676f1923e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import React, { Component } from 'react'
import VimeoPlayer from 'app/utils/vendor/vimeo'

import { CURTAIN_COLOR_LOOKUP } from 'app/constants'
import { SpeakerIcon } from '../../nav/viewer.icons'
import { MediaCitation } from '../components.media'

export const MediaVideo = ({ paragraph, media, currentParagraph, onAnnotationClick }) => {
  if (!media.lookup) return <div />
  // const { color } = element
  const className = currentParagraph ? 'media video current' : 'media video'
  const annotation = paragraph.annotations[0]
  const item = media.lookup[annotation.settings.media_id]
  if (!item) return <div>Media not found: {annotation.settings.media_id}</div>
  const color = CURTAIN_COLOR_LOOKUP[annotation.settings.color] || CURTAIN_COLOR_LOOKUP.white
  const width = window.innerWidth
  const height = window.innerHeight - (17 * 16)
  const style = {
    color: color.textColor,
    height: height + 32,
    backgroundColor: color.backgroundColor,
  }
  const poster = annotation.settings.poster ? {
    backgroundImage: 'url(' + item.settings.video.thumbnail_url + ')',
    backgroundSize: '50%',
    backgroundPosition: 'center center',
    backgroundRepeat: 'no-repeat',
  } : {}
  // console.log(annotation.settings)
  return (
    <div
      className={className}
    >
      <div className='videoPlayer' style={style}>
        <VimeoPlayer
          video={item.url}
          autoplay={annotation.settings.autoplay}
          muted={true}
          responsive={true}
          controls={false}
          byline={false}
          style={poster}
        />
      </div>
      <MediaCitation media={item} />
    </div>
  )
}