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 / src / components / presets / Video / VideoState.js
Size: Mime:
"use strict";

var __decorate = this && this.__decorate || function (decorators, target, key, desc) {
  var c = arguments.length,
      r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc,
      d;
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  return c > 3 && r && Object.defineProperty(target, key, r), r;
};

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

const mobx_1 = require("xmobx/mobx"); // I don't think we need it since we have native controls
// @observable isFocused = false


class VideoState {
  constructor(props) {
    // meta
    this.isPlaying = false;
    this.hasBeenPlayedAtLeastOnce = false; // props

    this.autoPlay = false;
    this.controls = false;
    this.setProps(props);
  }

  setIsPlaying(isPlaying) {
    this.isPlaying = isPlaying;
    console.debug('[Video] setIsPlaying: ' + isPlaying); // we have this to make sure

    if (isPlaying === true) {
      if (this.hasBeenPlayedAtLeastOnce === false) {
        this.hasBeenPlayedAtLeastOnce = true;
      }

      this.autoPlay = true;
      this.controls = true;
    }
  }

  toggleIsPlaying() {
    this.setIsPlaying(!this.isPlaying);
  }

  setProps(props) {
    this.autoPlay = props.autoPlay;
    this.controls = props.controls;
  }

}

__decorate([mobx_1.observable], VideoState.prototype, "isPlaying", void 0);

__decorate([mobx_1.observable], VideoState.prototype, "hasBeenPlayedAtLeastOnce", void 0);

__decorate([mobx_1.observable], VideoState.prototype, "autoPlay", void 0);

__decorate([mobx_1.observable], VideoState.prototype, "controls", void 0);

__decorate([mobx_1.action], VideoState.prototype, "setIsPlaying", null);

__decorate([mobx_1.action.bound], VideoState.prototype, "toggleIsPlaying", null);

__decorate([mobx_1.action], VideoState.prototype, "setProps", null);

exports.VideoState = VideoState;
exports.default = VideoState; //# sourceMappingURL=VideoState.js.map