Media Player in Sharepoint WSS3.0/ MOSS 2007 / Sharepoint 2010 by passing video url as querystring parameter
By placing the below code in the CEWP a Windows Media Player object will be placed on the page to play audio / video. You can pass the url of the media file as querystring parameter.
//Get request parameters through JavaScript
function getParameter ( queryString, parameterName ) {
// Add "=" to the parameter name (i.e. parameterName=value)
var parameterName = parameterName + "=";
if ( queryString.length > 0 ) {
// Find the beginning of the string
begin = queryString.indexOf ( parameterName );
// If the parameter name is not found, skip it, otherwise return the value
if ( begin != -1 ) {
// Add the length (integer) to the beginning
begin += parameterName.length;
// Multiple parameters are separated by the "&" sign
end = queryString.indexOf ( "&" , begin );
if ( end == -1 ) {
end = queryString.length
}
// Return the string
return unescape ( queryString.substring ( begin, end ) );
}
// Return "null" if no parameter has been found
return "null";
}
}
//Replace * by empty string
<* object classid="CLSID:22D6F312-B0F6-11D0-94AB-0080C74C7E95" width="600" height="400" id="mediaplayer1" title="Media Player" >
<* param name="FileName" value=getParameter(window.top.location.search.substring(1),"mediaurl") >
<* param name="AutoStart" value="True" >
<* param name="ShowControls" value="True" >
<* param name="ShowStatusBar" value="False" >
<* param name="ShowDisplay" value="False" >
<* param name="AutoRewind" value="True" >
<* param name="DisplayBackColor" value="True" / >
<* param name="BufferingTime" value="6" >
<* param name="allowfullscreen" value="true">
<* param name="allowscriptaccess" value="always">
<* embed src=getParameter(window.top.location.search.substring(1),"mediaurl") width="600" height="400" autostart="True" type="application/x-mplayer2"
pluginspage="http://www.microsoft.com/Windows/Downloads/Contents/MediaPlayer/" filename=getParameter(window.top.location.search.substring(1),"mediaurl") showcontrols="True" showstatusbar="False" showdisplay="False" autorewind="True" displaybackcolor="True" bufferingtime="6" >
<* /embed >
<* /object >
No comments:
Post a Comment