var Simple_Video = function () {

    var _self = this;
    var _data = null;
    var _simple_video_1 = null;
    var _mediaManager = null;

    var __options = {
        controls: true,
        autoplay: true,
        preload: 'auto',
        liveui: true,
        fill: true,
        responsive: true,
        seekButtons: {
            forward: 30,
            back: 10
        },
        userActions: {
            click: false
        },
        playbackRates: [0.5, 1, 1.5, 2],
        controlBar: {
            fullscreenToggle: false,
            playToggle: {
                replay: true
            }
        },
        volumePanel: {
            inline: false,
            vertical: true
        }
    };


    var _options = {
        controls: false,
        autoplay: true,
        preload: 'auto',
        fullscreenToggle: false,
        volumePanel: {
            inline: false,
        }
    };



    this.init = function (data) {
        //  Utils.clear();
        //  console.log('Simple_Video: init:    ', data);
    
        $("#btn_cc").removeClass("CC_disabled");

        _data = data;
        try {
            if (window.vPlayer) {
                window.vPlayer.dispose()
            }
            _simple_video_1 = videojs('simple_video_1', _options);
            window.vPlayer = _simple_video_1;
            _data['player'] = _simple_video_1;
        } catch (err) {
            console.error(err)
        }

        try {
            //  _mediaManager = window['course']['data']['mediaManager']
            _mediaManager = MediaManager;
            _mediaManager.init(_data);
        } catch (err) {
            console.error(err)
        }

        _self['manager'] = _mediaManager
    }


    this.updateData = function (data) {
        try {
            _data = data;
            //     console.log('Simple_Video: updateData:    ', data);
        } catch (err) {
            Utils.error(err)
        }
    }

    this.getData = function () {
        try {
            return _data;
        } catch (err) {
            Utils.error(err)
        }
    }

    this.changeVideo = function (vData) {
        try {
            var _videoData = vData;
            _videoData["callback"] = vData["callback"] || function () {
                //      console.log("audio .. completed....", vData)
            }
            _simple_video.updateMedia(_videoData);
        } catch (err) {
            Utils.error(err)
        }
    }

    this.updateMedia = function (data) {
        try {
            _mediaManager = MediaManager;
            data['player'] = _simple_video_1;
            //   _mediaManager = window['course']['data']['mediaManager']
            _self.updateData(data);
            _mediaManager.updateMedia(data);
        } catch (err) {
            Utils.error(err);
        }
    };

    this.playInitially = function (vData) {
        var _videoData = vData;
        _videoData["callback"] = vData["callback"] || function () {
            //    console.log("video .. completed....", vData)
        }

        data['player'] = _simple_video_1;
        _mediaManager.playInitially(_videoData);
    }

    this.stopVideo = function () {
        _mediaManager.pause();
    }

    this.gotoAndPlay = function (cTime) {
        _mediaManager.gotoAndPlay(cTime);
    }

    this.play = function () {
        _mediaManager.play();
    }

    this.pause = function () {
        _mediaManager.pause();
    }

    this.gotoAndStopEnd = function () {
        _mediaManager.gotoAndStopEnd();
    }

    return _self;
}