﻿/// <reference name="MicrosoftAjax.js"/>
Type.registerNamespace("aorta.playmeweb.webcontrols");

aorta.playmeweb.webcontrols.Status = function() {
    aorta.playmeweb.webcontrols.Status.initializeBase(this);

    this._imagemStatus = null;
    this._urlImagemCarregando = null;
    this._urlImagemParado = null;
    this._urlImagemTocando = null;
    this._urlImagemVolumeMinimo = null;
    this._player = null;

    //Cria as delegates
    this._player_onStatusChangedDelegate = null;
}

aorta.playmeweb.webcontrols.Status.prototype = {
    initialize: function() {
        aorta.playmeweb.webcontrols.Status.callBaseMethod(this, 'initialize');

        this._player_onStatusChangedDelegate = Function.createDelegate(this, this._player_onStatusChangedHandler);

        //Cria os handlers para os eventos
        this._player.add_statusChanged(this._player_onStatusChangedDelegate);
    },

    dispose: function() {
        aorta.playmeweb.webcontrols.Status.callBaseMethod(this, 'dispose');

        //Remove os handlers para os eventos
        this._player.remove_statusChanged(this._player_onStatusChangedDelegate);
    },

    _player_onStatusChangedHandler: function(sender, args){
        var status = this.get_player().get_status();

        switch(status){
            case aorta.playmeweb.webcontrols.EstadoPlayer.carregando:
                if(this.get_urlImagemCarregando())
                    this.get_imagemStatus().src = this.get_urlImagemCarregando();
                break;
            case aorta.playmeweb.webcontrols.EstadoPlayer.tocando:
                if(this.get_urlImagemTocando())
                    this.get_imagemStatus().src = this.get_urlImagemTocando();
                break;
            case aorta.playmeweb.webcontrols.EstadoPlayer.parado:
                if(this.get_urlImagemParado())
                    this.get_imagemStatus().src = this.get_urlImagemParado();
                break;
            case aorta.playmeweb.webcontrols.EstadoPlayer.mudo:
                if(this.get_urlImagemVolumeMinimo())
                    this.get_imagemStatus().src = this.get_urlImagemVolumeMinimo();
                break;
        }
    },

    get_imagemStatus: function(){
        /// <value type="String" locid="P:J#aorta.playmeweb.webcontrols.Status.imagemStatus"></value>
        if (arguments.length !== 0) throw Error.parameterCount();
        return this._imagemStatus;
    },
    set_imagemStatus: function(value){
        var e = Function._validateParams(arguments, [{name: "value", type: Object}]);
        if (e) throw e;
        this._imagemStatus = value;
    },

    get_urlImagemCarregando: function(){
        /// <value type="String" locid="P:J#aorta.playmeweb.webcontrols.Status.urlImagemCarregando"></value>
        if (arguments.length !== 0) throw Error.parameterCount();
        return this._urlImagemCarregando;
    },
    set_urlImagemCarregando: function(value){
        var e = Function._validateParams(arguments, [{name: "value", type: String}]);
        if (e) throw e;
        this._urlImagemCarregando = value;
    },

    get_urlImagemParado: function(){
        /// <value type="String" locid="P:J#aorta.playmeweb.webcontrols.Status.urlImagemParado"></value>
        if (arguments.length !== 0) throw Error.parameterCount();
        return this._urlImagemParado;
    },
    set_urlImagemParado: function(value){
        var e = Function._validateParams(arguments, [{name: "value", type: String}]);
        if (e) throw e;
        this._urlImagemParado = value;
    },

    get_urlImagemTocando: function(){
        /// <value type="String" locid="P:J#aorta.playmeweb.webcontrols.Status.urlImagemTocando"></value>
        if (arguments.length !== 0) throw Error.parameterCount();
        return this._urlImagemTocando;
    },
    set_urlImagemTocando: function(value){
        var e = Function._validateParams(arguments, [{name: "value", type: String}]);
        if (e) throw e;
        this._urlImagemTocando = value;
    },

    get_urlImagemVolumeMinimo: function(){
        /// <value type="String" locid="P:J#aorta.playmeweb.webcontrols.Status.urlImagemVolumeMinimo"></value>
        if (arguments.length !== 0) throw Error.parameterCount();
        return this._urlImagemVolumeMinimo;
    },
    set_urlImagemVolumeMinimo: function(value){
        var e = Function._validateParams(arguments, [{name: "value", type: String}]);
        if (e) throw e;
        this._urlImagemVolumeMinimo = value;
    },

    get_player: function(){
        /// <value type="String" locid="P:J#aorta.playmeweb.webcontrols.Status.player"></value>
        if (arguments.length !== 0) throw Error.parameterCount();
        return this._player;
    },
    set_player: function(value){
        var e = Function._validateParams(arguments, [{name: "value", type: Sys.Component}]);
        if (e) throw e;
        this._player = value;
    }
}

aorta.playmeweb.webcontrols.Status.registerClass('aorta.playmeweb.webcontrols.Status', Sys.Component);

if (typeof(Sys) !== 'undefined') Sys.Application.notifyScriptLoaded();
if(typeof(Sys)!=='undefined')Sys.Application.notifyScriptLoaded();