using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using QuintoCaminoV2.Data_objects;

namespace QuintoCaminoV2.Admin
{
    public partial class CharlasDetalle : System.Web.UI.Page
    {
        public int intCharlaId; 

        protected void Page_Load(object sender, EventArgs e)
        {
            intCharlaId = Convert.ToInt32(Request.QueryString["idCharla"]);
            BindData(intCharlaId);
            
            //try
            //{

            //    string mySourceUrl = Server.MapPath("~/uploads/Wildlife.wmv");
            //    cVideo.Attributes.Add("src", Server.MapPath("~/uploads/Wildlife.wmv")
            //    bool isFullSize = false;
            //    this.Literal1.Text = this.GetWmaObject(mySourceUrl, isFullSize);
            //}
            //catch (Exception ex)
            //{
            //    this.Response.Write(ex.ToString());
            //}

        }

        public void player(string NameVideo)
        {
            try
            {

                string path = "\\uploads\\Charlas" + NameVideo;
                sampleMovie.Attributes.Add("src", path);
                sampleMovie.DataBind();

            }
            catch (Exception ex)
            {
                Response.Write(ex.ToString());
            }
        }

        private string GetWmaObject(string sourceUrl, bool isFullSize)
        {
            string myObjectTag = "";
            sourceUrl = sourceUrl + "";
            sourceUrl = sourceUrl.Trim();



            if (sourceUrl.Length > 0)
            {
                //Continue.
            }
            else
            {
                throw new System.ArgumentNullException("sourceUrl");
            }

            string myWidthAndHeight = "";



            if (isFullSize)
            {
                myWidthAndHeight = "";
            }
            else
            {
                myWidthAndHeight = "width='640' height='480'";
            }



            myObjectTag = myObjectTag + "<object classid='CLSID:22D6F312-B0F6-11D0-94AB-0080C74C7E95' id='player' " + myWidthAndHeight + " standby='Please wait while the object is loaded...'>";
            myObjectTag = myObjectTag + "<param name='url' value='" + sourceUrl + "' />";
            myObjectTag = myObjectTag + "<param name='src' value='" + sourceUrl + "' />";
            myObjectTag = myObjectTag + "<param name='AutoStart' value='true' />";
            myObjectTag = myObjectTag + "<param name='Balance' value='0' />"; //-100 is fully left, 100 is fully right.
            myObjectTag = myObjectTag + "<param name='CurrentPosition' value='0' />"; //Position in seconds when starting.
            myObjectTag = myObjectTag + "<param name='showcontrols' value='true' />"; //Show play/stop/pause controls.
            myObjectTag = myObjectTag + "<param name='enablecontextmenu' value='true' />"; //Allow right-click.
            myObjectTag = myObjectTag + "<param name='fullscreen' value='" + isFullSize.ToString() + "' />"; //Start in full screen or not.
            myObjectTag = myObjectTag + "<param name='mute' value='false' />";
            myObjectTag = myObjectTag + "<param name='PlayCount' value='1' />"; //Number of times the content will play.
            myObjectTag = myObjectTag + "<param name='rate' value='1.0' />"; //0.5=Slow, 1.0=Normal, 2.0=Fast
            myObjectTag = myObjectTag + "<param name='uimode' value='full' />"; // full, mini, custom, none, invisible
            myObjectTag = myObjectTag + "<param name='showdisplay' value='true' />"; //Show or hide the name of the file.
            myObjectTag = myObjectTag + "<param name='volume' value='50' />"; // 0=lowest, 100=highest
            myObjectTag = myObjectTag + "</object>";



            return myObjectTag;
        }

        protected void BindData(int idCharla)
        {


            
            DataLayer oDataLayer = new DataLayer();
            Data_objects.Charlas oCharlas = new Data_objects.Charlas();
            oCharlas.intCharlaId = idCharla;


            //if (oCom.SortExpression == "Editar")
            //{
            foreach (Data_objects.Charlas objCha in oDataLayer.get_Charlas_by_Id(oCharlas))
            {
                //hidId.Value = objCha.intCharlaId.ToString();
                txtTitulo.Value = objCha.vchTitulo;
                txtFcharla.Value = objCha.vchFecha;
                txtDescCorta.Value = objCha.vchDescripcionCorta;
                chkActivo.Checked = objCha.bitActivo == true ? true : false;
                lblVideo.InnerHtml= objCha.vchUrl;
                player(objCha.vchUrl);

            }
            //btnAceptar.Text = "Actualizar";
            //ModalPopupExtender1.Show();
            ////}


        }
    }
}