次の方法で共有


Circumventing an IE/Flash Display Issue in the WPF WebBrowser control on x64 machines

Recently I wrote some code with the intent to display an embedded YouTube Flash video in Window Presentation Foundation’s WebBrowser control. I ran into an interesting problem. Internet Explorer displayed a broken object icon on some machines, but not others. After some investigation it appeared that the Flash video was displaying properly on x86 machines and failing to appear on x64 machines. Apparently the x64 build of the WPF application spawns an x64 instance of IE. The Flash object does not display, since IE attempts to load the x64 version of Flash, which incidentally does not yet exist for x64 versions of Windows.

To solve the problem, set the compiler to explicitly compile the app to x86, and it becomes a non-issue. The downside is that the app can no longer take advantage of x64 capabilities, but for many cases this is probably fine.

Incidentally here is the code that I used:

private string embedded = "<html style=\"margin:0 0 0 0; background-color:Black; overflow:hidden\">" +
"<script event=onload for=window>document.body.scroll=\"no\"</script>"+ "<object width=\"425\" height=\"344\">" +
"<param name=\"movie\" value=\"https://www.youtube.com/v/{0}&hl=en&fs=1\"></param>" +
"<param name=\"allowFullScreen\" value=\"true\"></param>" + "<param name=\"allowscriptaccess\" value=\"always\"></param>" +
"<embed src=\"https://www.youtube.com/v/{0}&hl=en&fs=1\" type=\"application/x-shockwave-flash\" allowscriptaccess=\"always\" allowfullscreen=\"true\" width=\"425\" height=\"344\"></embed>" +
"</object></html>";

WebBrowser wb = new WebBrowser();
wb.Width = 425;
wb.Height = 344;
wb.NavigateToString(string.Format(embeded, passInPathToVideo));