var Simple_Audio = function() {

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

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


    this.init = function(data) {
        //  Utils.clear();
    //    console.log('Simple_Audio: init:    ', data);
        _data = data;
        try {
            if (window.aPlayer) {
                window.aPlayer.dispose()
            }
            window.aPlayer = videojs('simple_audio_1');
            _data['player'] = window.aPlayer;
        } catch (err) {
            console.error(err)
        }

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

        _self['manager'] = _mediaManager
    }


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

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

    this.changeAudio = function(aData) {
        try {
            var _audioData = aData;
            _audioData["callback"] = aData["callback"] || function() {
         //       console.log("audio .. completed....", aData)
            }
            _simple_audio.updateMedia(_audioData);
        } catch (err) {
            Utils.error(err)
        }
    }

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

    this.playInitially = function(aData) {
        var _audioData = aData;
        _audioData["callback"] = aData["callback"] || function() {
      //      console.log("audio .. completed....", aData)
        }

        _data['player'] = window.aPlayer;
        data['player'] = _data['player'];
        _mediaManager.playInitially(_audioData);
    }

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

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

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

    return _self;
}