How to Add Videos to MOSS 2007 Web Part Pages

I have been meaning to figure out how to play WMV and other file formats directly in a SharePoint 2007 Web pages. My students and colleagues have been waiting for me to figure this out because everyone seems to be interested in playing videos in a SharePoint Web site. My business clients who deal with a lot of videos and have now migrated to a SharePoint environment have a business need to embed videos on their pages. You can embed videos in SharePoint in various ways. For example, you can embed YouTube videos or embed videos in other formats, such as WMV, AVI, or MPEG. Playing YouTube Videos in SharePoint Adding YouTube videos to a SharePoint page is easy. Just follow these steps. 1. Go to YouTube and select the video you want. 2. Simply click on the embed box just below the URL box in the top right hand corner of the page and copy the embedded code. 3. Paste the code into the HTML code (Source Editor) of the Content Editor Web Part. 4. Your video will play in the Content Editor Web Part page. Playing WMV Videos in SharePoint Playing WMV files in SharePoint is a bit more involved. Microsoft doesn't offer any solution out of the box and I was looking for a free solution that doesn't involve third-party products or purchasing Web parts. I tried several solutions that are out there, none of them really worked properly or were just too cumbersome to implement. I finally found a MediaPlayerWebPart written by Steve Sofian. I found the reference to the Web part on Alex Pearce's blog. This Web part worked like a charm. Here are all the details on how you can install and use this Web part to play WMV, AVI or MPEG videos on a SharePoint page. The following instructions apply to Windows Server 2008 and Microsoft Office SharePoint Server (MOSS) 2007 and assume that you are logged in with administrative rights to the MOSS 2007 and Windows Server 2008.
NOTE: If you are an end user or a Site Owner then you may need to ask your IT department for help. Once they have installed the MediaPlayerWebPart you will be able to add it to your Web part pages and play videos.
1. Download the MediaPlayerWebPart. 2. Unzip the file and copy the file MediaPlayerWebPart.dll to the bin folder on your hard drive. On Windows Server 2008 the folder is typically located in a location similar to C:\inetpub\wwwroot\wss\VirtualDirectories\www.seattlepro.com80\bin, where www.seattlepro.com is your Web site. 3. Open Notepad and load the web.config file located in the root of your Web site. For example, on Windows Server 2008 you will typically go to C:\inetpub\wwwroot\wss\VirtualDirectories\80 folder. 4. Add the following code just above the line </SafeControls>. This will add the code within the <SafeControls> and </SafeControls> section. The easiest thing is to do a search (CTRL-F) while in Notepad and look for </SafeControls>, then add the following code above that line and then save the file.
<SafeControl Assembly="MediaPlayerWebPart, version=1.0.0.0, Culture=neutral, PublicKeyToken=4907dffeafb11512" Namespace="NFWebParts" TypeName="*" Safe="True" />
Warning! You should copy the above code from my Web site into Notepad and then copy it from your Notepad into the web.config file. Otherwise, there's a chance that the copy command may add additional code that can mess up the results. 5. Once you've made the change to the web.config file, be patient while your site restarts. 6. Go to Site Actions, Site Settings, (then Modify All Site Settings for a publishing site) and under the Gallery section click Web Parts. 7. On the Web Part Gallery page click New. 8. At the bottom of the list you will find the MediaPlayerWebPart. [If you do not see it listed then check the troubleshooting section below.] Click the box next to it and then click Populate Gallery button located at the top of the page. 9. You will see the gallery populated with the new Web part. 10. At this point you have installed the new Web part and are ready to use it on your site. Using the MediaPlayerWebPart To use the Web part on your SharePoint site, you need to add Media Player Web Part to your Web part page. 1. Create (or open) a Web part page. 2. Add the Media Player Web Part (MPWP) located in the Misc section. 3. When the MPWP is loaded, modify the shared Web part. 4. There are a couple of changes you need to make. First, add the path to the media file you want to play in Media Source box. 5. In the MediaPlayerWidth and MediaPlayerHeight boxes type an appropriate number for the size of the media player. Depending on the download speed of the network, not everyone can take advantage of larger media player size. For starters, you might want to experiment with the following numbers. MediaPlayerWidth = 320 MediaPlayerHeight = 240 If your  video file was created in a larger format (e.g. 1024x768) then you may have to use these numbers or else your video may get cropped. 6. Click OK and exit the editing mode. Troubleshooting Tips Here are a few points to keep in mind if you are not able to get the Web part working properly. 1. If you are not seeing the MediaPlayerWebPart when you try to add it to your gallery it may be because you didn't edit the correct web.config file. 2. Check the code and make sure you added it to the correct section of the web.config file. 3. Copy the code first to the Notepad from my Web site and then copy it to your web.config file to make sure that the Web page didn't mess up the code. 4. Verify that you have added the Web part DLL to the correct bin folder. 5. If your Web part is not playing the WMV file, make sure that you have Windows Media Player installed on your computer. If you are working on the MOSS server you may not have the Windows Media Player installed. 6. If you are using Mozilla Firefox, you may need the appropriate plug-in to watch the Windows Media Player video.
Copyright ©2009 Zubair Alexander. All rights reserved.