views:

448

answers:

2

Hello everyone,

I have a WPF WebBrowser object in my application in which I am trying to view an isolated YouTube video. Every time the WebBrowser navigates to this YouTube video, I (the user) am presented with a dialog box stating the following:

File Download - Security Warning
Do You Want to Open or Save this file?

Is there any way to avoid this dialog? The address I am using for the YouTube video is formatted like this (for example):
http://www.youtube.com/v/EVCkSMwaGGc&hl=en&fs=1&

+1  A: 

Hey Chrisc!

I think this problem is not related to WPF or WebBrowser control. If you sniff traffic from YouTube you find that content-type is application/x-shockwave-flash. It looks like IE reacts on this content type with Save file dialog.

But what you can do is create a standalone html and refer it to the video you are trying to show. Something like this:

<html>
    <head>
        <title>YouTube Video</title>
    </head>
    <body>
        <object height="100%" width="100%">
            <param name="movie" value="http://www.youtube.com/v/8VQ4f22-SeE&amp;hl=ru&amp;fs=1&amp;"&gt;
            </param><param name="allowFullScreen" value="true">
            </param><param name="allowscriptaccess" value="always">
            </param>
            <embed src="http://www.youtube.com/v/8VQ4f22-SeE&amp;hl=ru&amp;fs=1&amp;" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="100%" height="100%">
            </embed>
        </object>
    </body>
</html>

Note, original video from your post cannot be embeded, because of permissions.

PS: To see the actual traffic I'm using FireFox + FireBug.

Anvaka
Thanks Anvaka. I tried your suggestion, and it worked nicely. Yes, I do know that my link cannot be embedded. I was just using it as an example to show the link format.
Chrisc
A: 

Well. the WPF browser is simply a wrapper around internet explorer. If you try navigating to the same URL in IE, you´ll find that it behaves exactly the same way.

What you probably need to do is generate a string something like the following: "" and load that instead.

Simon Söderman
wow stackoverflow messed up my html string :) but another guy already posted a nicer formatted solution so!
Simon Söderman