Figure 1
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:
- 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"
- Open SharePoint 2010 Central Administration, go to System Settings/Manage farm solutions. Deploy QuestechFlashMovie.wsp to select web application(s).
- 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:
...
<%@ 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" />
...