Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles / productivity / SharePoint

Flash Movie Field (SharePoint 2010)

4.50/5 (4 votes)
1 May 2010CPOL3 min read 52.6K   938  
Custom Flash Movie Field to render Flash movies

Figure 1

Figure 1

Figure 2

Figure 2

Introduction

Flash Movie Field is a custom field to render Flash movies and YouTube videos in SharePoint 2010. It uses the excellent swfobject to render the HTML and JavaScript for maximum browser compatibility. In edit mode, authors specify the Url, Width, and Height of the Flash movie. Optional parameters can be added easily by modifying the attached source code.

This is adapted from my WSS 3.0 version for SharePoint 2010.

Description

The Flash Movie Field is based on a new Field Type SPFieldFlashMovie. It has the following properties or column values:

  • Url - URL to Flash (.swf) movie or YouTube video, e.g. /media/map.swf, http://www.youtube.com/v/dMH0bHeiRNg&hl=en&fs=1.
  • Width - Width of Flash movie or YouTube video in pixels. For YouTube video, width includes embedded player.
  • Height - Height of Flash movie or YouTube video in pixels. For YouTube video, height includes embedded player.

Rendering is provided by a custom Field Control FlashMovieField with an associating Rendering Template QuestechFlashMovieFieldTemplate. All UI strings are localized and stored in resource files.

  • \ClientScripts\swfobject.js
    Support JavaScript file for swfobject. Set as Embedded Resource.
  • \ControlTemplates\QuestechFlashMovieFieldTemplate.ascx
    Form edit view of FlashMovieField with RenderingTemplate control.
  • \Fields\SPFieldFlashMovie.cs
    Field Type for custom Flash Movie field. Inherits from SPFieldMultiColumn.
  • \Fields\SPFieldFlashMovieValue.cs
    A class of column values for SPFieldFlashMovie. Inherits from SPFieldMultiColumnValue.
  • \Resources\QuestechCoreFlashMovie.resx
    WSS provisioning resource file and application run-time resource file for localized UI strings. This sets the display name for the custom field and the label strings for properties Url, Width, and Height during authoring. Deploys to ..\14\Resources\.
  • \WebControls\FlashMovieField.cs
    Field Control for SPFieldFlashMovie. Uses swfobject 2.2 to render Flash movies and YouTube videos.
  • \XML\fldtypes_SPFieldFlashMovie.xml
    Field Type Definition for Field Type SPFieldFlashMovie.
  • \Resource.resx
    Project resource file for localized UI strings.
  • \Utility.cs
    Utility file for common methods and properties.

The sample Visual Studio 2010 solution includes all the support files you need to build and deploy the custom field, minus the strong name key file (key.snk). It makes full use of the built-in SharePoint integration. No more third party tools or custom pre and post build scripts are needed to build the SharePoint solution file. 

Installation

To deploy the custom field, follow the procedures below:

  1. Open SharePoint 2010 Management Shell, add solution file QuestechFlashMovie.wsp using Add-SPSolution like:
    Add-SPSolution "C:\QuestechSystems.FlashMovie\bin\Release\QuestechFlashMovie.wsp"

    Or using stsadm, add solution file QuestechFlashMovie.wsp like:

    stsadm -o addsolution 
        -filename "C:\QuestechSystems.FlashMovie\bin\Release\QuestechFlashMovie.wsp"
  2. Open SharePoint 2010 Central Administration, go to System Settings/Manage farm solutions. Deploy QuestechFlashMovie.wsp to select web application(s).
  3. Go to the top site in the selected web application(s). Activate Site Collection feature Questech Systems Flash Movie Columns.

The custom Flash Movie Field should now be ready for use. You can go to the Site Columns gallery to verify. To use the custom field in your SharePoint page, you would first need to add the custom site column to a content type by going to the Site content types gallery. In the gallery listing, select a content type and click Add from existing site columns.

In your page layout file, modify the code as follows:

ASP.NET
...
<%@ Register Tagprefix="QuestechWebControls" 
    Namespace="QuestechSystems.SharePoint.WebControls"
    Assembly="QuestechSystems.SharePoint.FlashMovie, Version=1.0.0.0, 
    Culture=neutral, PublicKeyToken=f268fd4f0f42524c" %>

...
...
<QuestechWebControls:FlashMovieField FieldName="FlashMovieFile" runat="server" />
...

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)