summaryrefslogtreecommitdiff
path: root/animism-align/frontend/app/views/viewer/player/components.inline/inline.video.js
blob: d7cc9672b41d49e35314961237cb3b1d8299eeb5 (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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
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'
import { posterURL } from 'app/utils/annotation.utils'

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 height = window.innerHeight - (17 * 16)
  let style = {
    color: color.textColor,
    height: height + 32,
    backgroundColor: color.backgroundColor,
  }

  // if this is a fullscreen video, display the poster image
  if (annotation.settings.fullscreen && !annotation.settings.inline) {
    const color = CURTAIN_COLOR_LOOKUP[annotation.settings.poster_background_color || annotation.settings.color] || CURTAIN_COLOR_LOOKUP.white
    style.color = color.textColor
    style.backgroundColor = color.backgroundColor
    style.backgroundImage = 'url(' + posterURL(item) + ')'
    if (annotation.settings.poster_size) {
      style.backgroundSize = annotation.settings.poster_size
    }
    return (
      <div className={className}>
        <div
          className='videoPoster'
          style={style}
          onClick={e => onAnnotationClick(e, paragraph, annotation)}
        >
          <div className="speaker-icon">{SpeakerIcon}</div>
        </div>
        <MediaCitation media={item} />
      </div>
    )
  }

  const poster = annotation.settings.poster ? {
    backgroundImage: 'url(' + posterURL(item) + ')',
  } : {}
  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>
  )
}