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

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

const tslib_1 = require("tslib");

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.shouldAutoPlay = false;
    this.hasNativeControls = false;
    this.setProps(props);
    this.shouldAutoPlay = props.shouldAutoPlay;
    this.hasNativeControls = props.hasNativeControls;
  }

  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.shouldAutoPlay = this.shouldAutoPlay;
      this.hasNativeControls = this.hasNativeControls ? false : true;
    }
  }

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

  setProps(props) {
    this.shouldAutoPlay = props.shouldAutoPlay;
    this.hasNativeControls = props.hasNativeControls;
  }

}

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

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

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

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

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

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

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

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