Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Debian packages RPM packages NuGet packages

Repository URL to install this package:

Details    
@skava/ui-presets / dist / presets / Studio / Video / renderProps.js
Size: Mime:
"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});

const tslib_1 = require("tslib");

const react_1 = tslib_1.__importDefault(require("react"));

const exotic_1 = require("exotic");

const utils_1 = require("@skava/utils");

const Video_1 = require("@skava/ui/dist/components/atoms/Video");

const VideoControls_1 = require("./VideoControls");

const styled_1 = require("./styled");

const CONTROL_PROPS = Object.freeze(['state', 'videoLength', 'title', 'slogan', 'shareTitle']);
const VIDEO_PROPS = Object.freeze(['src', 'state', 'thumbnailImage', 'shouldAutoPlay', 'shouldLoop', 'preload', 'muted', 'hasNativeControls', 'hasPlayButton', 'shouldShowVideoInformation']);

function defaultRenderControls(props, state) {
  const controlProps = utils_1.keep(props, CONTROL_PROPS);
  return react_1.default.createElement(VideoControls_1.VideoControls, Object.assign({}, controlProps, {
    state: state
  }));
}

exports.defaultRenderControls = defaultRenderControls;

function defaultRenderVideo(props, state) {
  const {
    mp4Source
  } = props,
        remainingProps = tslib_1.__rest(props, ["mp4Source"]);

  const strippedProps = utils_1.omit(remainingProps, CONTROL_PROPS);

  const {
    src: videoUrl
  } = strippedProps,
        strippedRemainingProps = tslib_1.__rest(strippedProps // console.log('videoUrl', videoUrl)
  , ["src"]); // console.log('videoUrl', videoUrl)


  const videoSrc = exotic_1.fromIshToString(videoUrl[0]);

  if (videoSrc !== '') {
    const validVideoSrc = utils_1.toUrlWithProtocol(videoSrc);
    const src = [validVideoSrc];
    const videoProps = Object.assign({
      src
    }, strippedRemainingProps, {
      // props overwriting from state
      hasNativeControls: state.hasNativeControls,
      hasPlayButton: state.hasPlayButton,
      shouldShowVideoInformation: state.shouldShowVideoInformation,
      isPaused: !state.isPlaying,
      muted: strippedRemainingProps.shouldAutoPlay
    });
    return react_1.default.createElement(Video_1.VideoPlayer, Object.assign({}, videoProps));
  } else {
    return react_1.default.createElement(styled_1.PlaceholderImage, {
      src: 'https://raderain.sirv.com/placholders/play_icon.png'
    });
  }
}

exports.defaultRenderVideo = defaultRenderVideo;