C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Communities   Interview   Jobs   Projects   Offshore Development    
Silverlight Tutorials | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Revenue Sharing |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...

New Feature: Community Sites: Create your own .NET community website and start earning from Google AdSense ! It's Free !






Sharepoint prompts for Username/Password on clicking video files to open in Windows media player.


Posted Date: 30 Sep 2008    Resource Type: Articles    Category: Web Applications

Posted By: Gitolekha Ray       Member Level: Silver
Rating:     Points: 10



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://gps-s6188:82/_layouts/ad.aspx?lnk=http://gpchbs-s6188:82/Videos/machos.wm

in ad.aspx we pass the name of the document library, here videos and the file name, here machos.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 -> 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 -> 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 = CPD machos.wmv, so while encoding it is sent as below,
http://gpchbs-s6188:82/_layouts/ad.aspx?lnkftp=ftp://174.456.12.45/CPD%20machos.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://gpchbs-s6188:82/_layouts/ad.aspx?lnkftp=ftp://174.456.12.45/CPD%20machos.wmv
) anf final title is the title to be shown in the subject line of the mail.



For more details, visit http://techolyvia.wordpress.com/2008/09/30/sharepoint-prompts-for-usernamepassword-on-clicking-video-files-to-open-in-windows-media-player/




Responses


No responses found. Be the first to respond and make money from revenue sharing program.

Feedbacks      
Popular Tags   What are tags ?   Search Tags  
Stop left click  .  Sharepoint prompts for Username/Password on clicking video  .  Embed video files in web page  .  Email link  .  

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: how to fill the dropdownlist in the gridview
Previous Resource: Client Side validations for Text Boxes against white spaces, Date, Email
Return to Discussion Resource Index
Post New Resource
Category: Web Applications


Post resources and earn money!
 
Related Resources



dotNet Slackers   BizTalk Adaptors    Web Design

teleconferencing service

Contact Us    Privacy Policy    Terms Of Use