This project is read-only.

help with silverlight video extension

Jul 16, 2009 at 10:26 AM

I have been using the silverlight video extension in my blog for quite some time.  I've recently upgraded from 1.3 to 1.5 and I am having some difficulty getting the extension to work in the new environment.  I can get everything to load and function correctly on the localhost, but when I upload the files to the active server, then I am simply left with a blank placeholder (see here).  I am really a novice when it comes to programming, so I would be happy if someone could take a look at the extension code I am using and offer an opinion...

using System;
using BlogEngine.Core;
using System.Web;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Text.RegularExpressions;
using BlogEngine.Core.Web.Controls;
using System.IO;

/// <summary>
/// Adds a Silverlight video player to the post.
/// </summary>
[Extension("Adds a Silverlight video player to the post.", "1.0", @"<a href="""">Sean Blakemore</a>")]
public class SilverlightPlayer
    private static String playerSkins = Utils.RelativeWebRoot + "SilverlightPlayer/Skins/";
    private static String skins = "Blitz, Classic, Clean, Console, CorporateSilver, CorporateWhite, " +
        "Executive, Expression, Glassy, Minimalist, Pilot, Popup, Silverlight, Thin";

    private static ExtensionSettings settings;

    /// <summary>
    /// Adds a Silverlight video player to the post.
    /// </summary>
    public SilverlightPlayer()
        Post.Serving += Post_Serving;

        ExtensionSettings initialSettings = new ExtensionSettings(GetType().Name);
        initialSettings.Help = "Valid skins are: " + skins;
        initialSettings.AddParameter("contentRoot", "Content Root");
        initialSettings.AddValue("contentRoot", "SilverlightPlayer/");
        initialSettings.AddParameter("width", "Width");
        initialSettings.AddValue("width", "480");
        initialSettings.AddParameter("height", "Height");
        initialSettings.AddValue("height", "360");
        initialSettings.AddParameter("skin", "Skin");
        initialSettings.AddValue("skin", "Popup");
        initialSettings.IsScalar = true;
        settings = ExtensionManager.GetSettings(GetType().Name);

    private void Post_Serving(object sender, ServingEventArgs e)
        if (e.Location != ServingLocation.PostList && e.Location != ServingLocation.SinglePost)

        String regex = @"\[silverlight:.*?\.wmv\]";
        MatchCollection matches = Regex.Matches(e.Body, regex);

        if (matches.Count == 0)

        Int32 width;
        Int32 height;
        String skin;
        String xaml;

            width = Int32.Parse(settings.GetSingleValue("width"));
            height = Int32.Parse(settings.GetSingleValue("height"));
            skin = settings.GetSingleValue("skin");
            xaml = playerSkins + skin + "/player.xaml";
        { return; }


        for (int i = 0; i < matches.Count; i++)
            Int32 length = "[silverlight:".Length;
            String mediaFile = matches[i].Value.Substring(length, matches[i].Value.Length - length - 1);

            mediaFile = settings.GetSingleValue("contentRoot") + mediaFile;

            String player = @"<div id=""silverlightPlayer_{0}"" style=""width:{1}px; height:{2}px;"">
                                <script  type='text/javascript'>
                                    new StartPlayer_0(""silverlightPlayer_{0}"", ""{3}"", ""{4}"");

            e.Body = e.Body.Replace(matches[i].Value, String.Format(player,
                i, width, height, xaml, mediaFile));

    /// <summary>
    /// Inject JavaScript files into the header of the page.
    /// </summary>
    private void AddJavascriptToHeader(String skin)
        String[] javascriptFiles = new String[]
            skin + "/player.js"

        System.Web.UI.Page pg = (System.Web.UI.Page)HttpContext.Current.CurrentHandler;

        if (pg.Header.FindControl("SPJS0") == null)
            for (int i = 0; i < javascriptFiles.Length; i++)
                HtmlGenericControl js = new HtmlGenericControl("script");
                js.Attributes.Add("id", "SPJS" + i);
                js.Attributes.Add("type", "text/javascript");
                js.Attributes.Add("src", playerSkins + javascriptFiles[i]);


Jul 18, 2009 at 6:42 AM

Just checking to see if anyone has any thoughts on this issue...

It seems to me (very much a newbie) there may be an issue with the path, as the code seems to work (there is a blank placeholder installing where the video player should be located)... My blog is installed as a sub-domain and all else seems to work just fine.  I have made no significant changes to the set-up after upgrading to 1.5, except I did a fresh install and then copied in the necessary files from AppData and the Silverlight files...

Would really appreciate some direction as I am really a beginner with java and

Many thanks...

Jul 21, 2009 at 6:34 AM

Hate to be a bother, but just checking (again) to see if anyone has any ideas on a solution or how I may be able to fix this issue...I really appreciate the time spent by those on this forum who help others out with issues/problems - and I'm hoping someone in the world may have a solution... Not sure if I need to supply more information...

Many thanks...