6

i am trying to run a .swf file in my WPF application, i have created a html page and in that i have referenced my .swf file using object tag and then loading that html page in my Main Window

my xaml looks like

<Window x:Class="sirajflash.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="MainWindow" Height="350" Width="525">
    <Grid>
        <WebBrowser Name="myBrowser"></WebBrowser>
        <!--<Frame Name="myframe"/>--> //tried with frame also but no luck
    </Grid>
</Window>

assigning the source

   public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();

            myBrowser.Source = new Uri(CreateAbsolutePathTo("playflash.htm"), UriKind.Absolute);
        }
        private static string CreateAbsolutePathTo(string mediaFile)
        {
            return System.IO.Path.Combine(new FileInfo(Assembly.GetExecutingAssembly().Location).DirectoryName, mediaFile);
        }
    }

The Problem:

when i run the application the warning occurs that ActiveX content is trying to access etc etc and when i allow it nothing appears in my main window the warning keeps on occuring multiple times.

if i run the flash movie in the browser directly it runs just fine.

Regards.

H.B.
  • 166,899
  • 29
  • 327
  • 400
John x
  • 4,031
  • 8
  • 42
  • 67
  • Are you on x86 or x64 machine? – spender Sep 30 '11 at 07:52
  • @spender any sugeestions i can find a way out – John x Sep 30 '11 at 09:52
  • Its strange! I can load a local htm file from my C:\ hosting a local embedded swf file in a WPF `WebBrowser` control. I too got the warning at first but once I select "Allow Blocked Content" it works for me then on. – WPF-it Sep 30 '11 at 10:13
  • Perhaps you should consider adding the "mark of the web" to the hosted page: http://flash.fincanon.com/archives/162 and http://msdn.microsoft.com/en-us/library/ms537628%28VS.85%29.aspx – spender Sep 30 '11 at 10:41
  • @AngelWPF can you upload your sample project somwhere form where i can download and see what i am missing... – John x Oct 03 '11 at 04:26

2 Answers2

5
  1. I have a flash based clock as a .swf file on my C:\Test\MyClock.swf

  2. I have a htm file at C:\Test\MyHtml.htm

      <embed src=C:\Test\MyClock.swf
             width=200 height=200
             wmode=transparent type=application/x-shockwave-flash>
      </embed>
    
  3. I have web browser control as below...

    <Window x:Class="MyFlashApp.MainWindow"
       xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
       xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
       Title="MainWindow" Height="350" Width="525">
      <Grid>
        <WebBrowser Source="C:\Test\MyHtml.htm"></WebBrowser>
      </Grid>
    </Window>           
    
  4. On running the app, I see the webbrowser control giving warning as "To help protect your security, Internet Explorer has restricted this file from showing active content that could access your computer. Click here for options."

  5. I accept the warning by right click and the left click "Allow Blocked Content". A confirmation popup appears to which I say Yes.

  6. I see the Flash based clock.

WPF-it
  • 19,625
  • 8
  • 55
  • 71
  • thanks alot that worked i was doing it with the `` changing it to `embed` solved the problem – John x Oct 03 '11 at 05:21
  • Glad i could help. This suggests another point that we must post as much relevant source code as possible with our question. :-) – WPF-it Oct 03 '11 at 08:43
1

WebBrowser control can support flash directly . If you don't need to present anything in HTML then you can directly provide the path to the flash file .

myWebBrowser.Source  = "C:\Test\MyClock.swf"

However you will still get the IE warning message.

kiran
  • 1,062
  • 24
  • 31