<%@ Reference VirtualPath="~/bitrix/components/bitrix/media.player/component.ascx" %>
<%@ Control Language="C#" AutoEventWireup="false" Inherits="Bitrix.Main.Components.MediaPlayerComponentTemplate" %>
<%@ Import  Namespace="Bitrix.UI"%>
<%@ Import  Namespace="Bitrix.Main.Components"%>
<script runat="server">
    protected override void OnPreRender(EventArgs e)
    {
        base.OnPreRender(e);

        BXPage.RegisterScriptInclude("~/bitrix/controls/main/media.player/wmv/silverlight.js");
        BXPage.RegisterScriptInclude("~/bitrix/controls/main/media.player/wmv/wmvplayer.js");        
        BXPage.RegisterScriptInclude("~/bitrix/js/Main/utils_net.js");
        BXPage.RegisterScriptInclude("~/bitrix/controls/main/media.player/js/player.js");


        if (!Component.Parameters.ContainsKey("abouttext"))
            Component.Parameters["abouttext"] = Component.AboutText; //?

        if (!Component.Parameters.ContainsKey("aboutlink"))
            Component.Parameters["aboutlink"] = Component.AboutLink; //?

        System.Web.Script.Serialization.JavaScriptSerializer jsSerializer = new System.Web.Script.Serialization.JavaScriptSerializer();
        StringBuilder sb = new StringBuilder();
        jsSerializer.Serialize(Parameters, sb);
        ScriptManager.RegisterStartupScript(
            this,
            GetType(),
            string.Concat("register", Component.ClientID), //Разрешаем мульти-экземплярность 
            string.Format("window.setTimeout(function(){{ Bitrix.MediaPlayer.messages = {{ installFlashPlayer:'{3}', couldntCreatePlayer:'{4}', couldntCreateFlashPlayer:'{5}', couldntCreateSilverlightPlayer:'{6}' }};  Bitrix.MediaPlayer.create('{0}', '{1}', Bitrix.MediaPlayerData.create({2})).activate(); }}, 100);\r\n", 
                Component.ClientID, 
                string.Concat(Component.ClientID, "_Container"), sb.ToString(), 
                GetMessageJS("InstallFlashPlayer"), 
                GetMessageJS("CouldntCreatePlayerErrorMsg"), 
                GetMessageJS("CouldntCreateFlashPlayerErrorMsg"), 
                GetMessageJS("CouldntCreateSilverlightPlayerErrorMsg")),
            true);        
    }    
</script>
<div id="<%= HttpUtility.HtmlAttributeEncode(string.Concat(Component.ClientID, "_Container")) %>"></div>

