We have observed in different cases, suppose we have a video file in a sharepoint library, if we click the file  it prompts for username/password. It is not very user friendly, as the password needs to be entered every time.

 

After some searches we found many people facing this problem so we suggested that we can open the video in a web page instead of opening it in Windows Media Player.

 

So, we created an aspx page in _layouts folder.

Now, whenever the user clicks to open a video file, we redirect it to the aspx page like,

 

http://gitolekha/_layouts/ad.aspx?lnk=http://gitolekha/Videos/sharepoint.wm

 

in ad.aspx we pass the name of the document library, here videos and the file name, here gito sharepoint.wm

 

here, we embed the video file in the aspx web page,

 

< OBJECT id="MediaPlayer" CLASSID="CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95">

<PARAM NAME="SRC" VALUE=<%=strVal %>>

<PARAM NAME="AUTOSTART" VALUE="1><PARAM NAME="SHOWCONTROLS" VALUE="1"><param name="ShowStatusBar" value="1">

</OBJECT >

 

strVal is the name of the file which we get from the code behind,

 

if (Request.QueryString[“lnk”] != null)

{

   string strVal = Request.QueryString[“lnk”].ToString();

}

 Our job is done, we have embedded the video file in the webpage, so it dosen’t ask for username/password every time we try to open it as it was before when we opened it in Windows Media Player.

 

Now, how to download it?

We can always download from Sharepoint document library through some coding, but I am lazy, I want to leave it to the default download system of windows as right click -&gt; save as. How do we do that?

 

On top of the webpage I give a hyperlink as shown below, now I want to stop users from left clicking so that they are forced to right click -&gt; save target as.

 

<a href=<%=strVal %>; onMouseOver=’document.onmousedown=noLeftClick’ onMouseOut=’document.onmousedown=null’><b>Download File</b></a>;

 

 

<script language=”javascript”>

function noLeftClick()

{

   if (event.button==1)

   {

    alert(‘Please use the rightclick \”Save Target As\” Command to Download’)

    }

 }

<script>

 

Now, how do users send email of the link of the video to other users?

 

We send it as shown below to the same aspx page, however we need to encode it, here filename = gito sharepoint.wmv, so while encoding it is sent as below,

 

http://gitolekha/_layouts/ad.aspx?lnkftp=ftp://174.456.12.45/CPD%20sharepoint.wmv

 

see the code below,

void emailImage_DataBinding(object sender, EventArgs e)

{

 HyperLink mailImage = (HyperLink)sender;

mailImage.NavigateUrl = “mailto:?body=” + mailImage.Page.Server.UrlPathEncode(FinalLink + “&subject=Link to “ + fileTitle);

}

 

Here final link is the link shown above(http://gitolekha/_layouts/ad.aspx?lnkftp=ftp://174.456.12.45/gito%20sharepoint.wmv

) and final title is the title to be shown in the subject line of the mail.

 

Advertisements