import _defineProperty from 'babel-runtime/helpers/defineProperty';
import _extends from 'babel-runtime/helpers/extends';
import _classCallCheck from 'babel-runtime/helpers/classCallCheck';
import _createClass from 'babel-runtime/helpers/createClass';
import _possibleConstructorReturn from 'babel-runtime/helpers/possibleConstructorReturn';
import _inherits from 'babel-runtime/helpers/inherits';
import React, { Component } from "react";
import LocaleReceiver from 'antd/es/locale-provider/LocaleReceiver';
import defaultLocale from '../locale/default';

var Video = function (_Component) {
    _inherits(Video, _Component);

    function Video() {
        _classCallCheck(this, Video);

        var _this = _possibleConstructorReturn(this, (Video.__proto__ || Object.getPrototypeOf(Video)).apply(this, arguments));

        _this.creatVideo = function () {
            var _this$props = _this.props,
                playerProps = _this$props.playerProps,
                callBack = _this$props.callBack,
                local = _this$props.local;

            var player = new window.Aliplayer(_extends(_extends({}, playerProps), { language: local.name, languageTexts: _defineProperty({}, local.name, local.content) }), function () {
                callBack(player);
            });
        };
        return _this;
    }

    _createClass(Video, [{
        key: 'componentDidMount',
        value: function componentDidMount() {
            this.creatVideo();
        }
    }, {
        key: 'render',
        value: function render() {
            return React.createElement('div', { id: this.props.id });
        }
    }]);

    return Video;
}(Component);

function VideoPlayer(props) {
    var id = props.id,
        playerProps = props.playerProps,
        callBack = props.callBack;

    return React.createElement(
        LocaleReceiver,
        { componentName: 'VideoPlayer', defaultLocale: defaultLocale.VideoPlayer },
        function (locale) {
            return React.createElement(Video, { id: id, playerProps: playerProps, callBack: callBack, local: locale });
        }
    );
}
export default VideoPlayer;