Welcome to Office Zealot Sign in | Join | Help

speakTECH Flash Poster

 

The new OfficeZealot home page contains a Flash Poster. The speakTECH Flash Poster is a small but  nifty Flash movie that displays a series of images in sequence with nice animations and a couple of other interesting features.

 

Adding a Flash element to a Sharepoint page is pretty simple, just create a new web part that writes the appropriate object tag (you can also add through the content web part, but then we wouldn't have customizable properties):

 

  private string _transition;

        private string _displaytime;

 

        [WebBrowsable(true),

   Personalizable(PersonalizationScope.Shared),   

   WebDisplayName("Transition Time"),

         WebDescription("Number of transitions")]

        public string transition

        {

            get { return _transition; }

            set { _transition = value; }

        }

 

        [WebBrowsable(true),

         Personalizable(PersonalizationScope.Shared),

   WebDisplayName("Display Time"),

         WebDescription("Time in secs of each transition")]

        public string displaytime

        {

            get { return _displaytime; }

            set { _displaytime = value; }

        }

 

        protected override void Render(HtmlTextWriter writer)

        {

            StringBuilder sb = new StringBuilder();

           

            sb.Append( *Object Tag with properties* );

            writer.Write(sb.ToString());

        }

But in this case that’s not all, the speakTECH Flash Poster requires that we provide it an XML file with a specific schema so that it knows which images to render, for how long, and in which order.

The basic idea is to get all the images from a list, but Flash is not Sharepoint aware.

We created an ASPX page that can handle a simple GET request and created the XML output for Flash. With this we can receive a few parameters through the query string that point to the right list.

As you can see we decided to add some properties to the web part so the users can customize the web part however they like. The web part then sends the parameters to this ASPX page.

 

The following parameter is used in the object/embed tags to request a specific XML file.

 

<param name=\"param\" value=\"configxml=../site/page.aspx?param1=" + _transition + "&param2=" + _displaytime + ");

 

Once the ASPX page receives the request, we get the Document Libraty where the images are stored. It needs to be a document library and not a list since we want to store the images in Sharepoint. An alternative would be to use a List when the images are NOT in Sharepoint but hosted externally... many alternatives as usual.

The ASPX page then creates the XML structure we need, we get all the items from the Document Library/List and output the XML without too much fuss.

  SPList images = UIUtils.GetList("List");

 

        StringWriterUTF8 sw = new StringWriterUTF8();

        XmlTextWriter writer = new XmlTextWriter(sw);

 

        int tt = UIUtils.ParseInt(Request.QueryString["param1"], 2);

        int dt = UIUtils.ParseInt(Request.QueryString["param2"], 5);

 

        writer.WriteStartDocument();

        writer.WriteStartElement("slideshow");

 

        writer.WriteStartElement("config");

        writer.WriteElementString("transitiontime", tt.ToString());

        writer.WriteElementString("displaytime", dt.ToString());

        writer.WriteEndElement(); //end config

 

        writer.WriteStartElement("items");

 

        foreach (SPListItem item in images.Items)

        {

            writer.WriteStartElement("item");

            writer.WriteStartElement("src");

            writer.WriteCData("/"+item.File.Url);

            writer.WriteEndElement(); //end src

            writer.WriteElementString("type", "image");

            writer.WriteStartElement("link");

            if (item["link"] != null)

            {

                writer.WriteCData(item["link"].ToString());

            }

            else

            {

                writer.WriteCData("");

            }

            writer.WriteEndElement(); //end link

            writer.WriteStartElement("text");

            writer.WriteStartElement("header");

            if (item["header"] != null)

            {

                writer.WriteCData(item["header"].ToString());

            }

            else

            {

                writer.WriteCData("");

            }

            writer.WriteEndElement(); //end header

 

            writer.WriteStartElement("description");

            if (item["Description"] != null)

            {

                writer.WriteCData(item["Description"].ToString());

            }

            else

            {

                writer.WriteCData("");

            }

            writer.WriteEndElement(); //end Description

 

            writer.WriteEndElement(); //end text

 

            writer.WriteEndElement(); //end item

        }

        writer.WriteEndElement(); //end items

 

        writer.WriteEndElement(); //end slideshow

        writer.WriteEndDocument();

        SendXmlResponse(sw.ToString());

And that’s it. A nice, configurable Flash Poster driven by a Sharepoint list.

P.S. There are other ways to accomplish this that are more Sharepoint-esque; however, this is as simple at it gets.

Published Thursday, February 07, 2008 11:02 PM by omar2

Comments

No Comments
Anonymous comments are disabled