Figure 1
|
Figure 2
|
Introduction
Flash Movie Field is a custom WSS field to render Flash movies and YouTube videos. 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.
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. The resource files are split into three files, one for the project level, one for the web application level, and one for the WSS level.
- \SharePoint\ClientScripts\swfobject.js
Support JavaScript file for swfobject. Set as Embedded Resource.
- \SharePoint\Fields\SPFieldFlashMovie.cs
Field Type for custom Flash Movie field. Inherits from SPFieldMultiColumn.
- \SharePoint\Fields\SPFieldFlashMovieValue.cs
A class of column values for SPFieldFlashMovie. Inherits from SPFieldMultiColumnValue.
- \SharePoint\Receivers\AppGlobalResourcesFeatureReceiver.cs
Feature receiver that copies all resource files with the name starting Questech* in ..\12\CONFIG\Resources\ to ..\wss\VirtualDirectories\[port]\App_GlobalResources\ upon feature activation.
- \SharePoint\Resources\Resources.resx
Project resource file for localized UI strings.
- \SharePoint\RootFiles\CONFIG\Resources\QuestechSharePoint.resx
Application run-time resource file for localized UI strings. This sets the label strings for properties Url, Width, and Height during authoring. Deploys to ..\12\CONFIG\Resources\. Copies to ..\wss\VirtualDirectories\[port]\App_GlobalResources\ by the feature QuestechAppGlobalResources.
- \SharePoint\RootFiles\Resources\QuestechCoreSharePoint.resx
WSS provisioning resource file for localized UI strings. This sets the display name for the custom field. Deploys to ..\12\Resources\.
- \SharePoint\RootFiles\TEMPLATE\CONTROLTEMPLATES\QuestechFlashMovieFieldTemplate.ascx
Form edit view of FlashMovieField with RenderingTemplate control.
- \SharePoint\RootFiles\TEMPLATE\XML\fldtypes_SPFieldFlashMovie.xml
Field Type Definition for Field Type SPFieldFlashMovie.
- \SharePoint\WebControls\FlashMovieField.cs
Field Control for SPFieldFlashMovie. Uses swfobject 2.1 to render Flash movies and YouTube videos.
- \SharePoint\Utility.cs
Utility file for common methods and properties.
Two features are required for the deployment: QuestechAppGlobalResources and QuestechColumns. QuestechAppGlobalResources is responsible for copying web application resource files to the appropriate directory under the web application root. This is only required for existing web applications, not for new ones. QuestechColumns is responsible for deploying the custom Field Type Definition in fldtypes_SPFieldFlashMovie.xml.
Installation
The sample Visual Studio 2005 SP1 solution includes all the support files you need to build and deploy the custom field, minus strong name key files (*.snk). (The supplied Visual Studio 2005 solution contains Web Application projects supported only by SP1 or after.) It contains three projects: Deployment, Features, and SharePoint. The SharePoint project contains source code for the custom field. The Features project contains features to support the deployment. The Deployment project contains a pre-build script to aggregate all the files needed for deployment. It contains a Solution directory where a WSP file is generated and deployed by a post-build script.
This structure of Visual Studio solution and projects is designed to be scalable to full blown MOSS/WSS development and deployment. You could add additional projects like SharePoint.Publishing for MOSS Publishing development. Within your SharePoint or SharePoint.Publishing projects, you could have custom components like user controls, web controls, web parts etc.
To deploy the custom field, follow the procedures below:
- Using stsadm, install the solution file QuestechSolution.wsp in \Deployments\Solution\
stsadm -o addsolution -filename QuestechSolution.wsp
- Open SharePoint 3.0 Central Administration, go to Operations/Global Configuration/Solution Management. Deploy QuestechSolution.wsp to select web application(s).
- In SharePoint 3.0 Central Administration, go to Application Management/Manage Web application features. Select the web application(s) where the solution is deployed. Activate the feature Questech Systems Application Global Resources.
- Go to the top site in the selected web application(s). Activate the Site Collection feature Questech Systems Custom 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 MOSS page layout, 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 ASPX file, modify the code as follows:
...
<%@ Register Tagprefix="QuestechWebControls"
Namespace="QuestechSystems.SharePoint.WebControls"
Assembly="QuestechSystems.SharePoint, Version=1.0.0.0,
Culture=neutral, PublicKeyToken=f1874fca2a9b1c17" %>
...
...
<QuestechWebControls:FlashMovieField FieldName="FlashMovieFile" runat="server" />
...
References
- Create custom field type in WSS V3 - Jim Yang
- SharePoint Resources, Types, Use and Deployment - Mikhail Dikov
- swfobject
- Features for SharePoint - MSDN Magazine
- SharePoint 2007 Features “ Creating Site Columns and Content types - Share This Point
- Solution Deployment with SharePoint 2007 - MSDN Magazine
History
- V1.1 - 2008.08.12
- Added support of YouTube videos.
- Modified form view layout.
- Upgraded swfobject to V2.1
- V1.0 - 2008.04.26 - Base.