简体   繁体   中英

How to play swf file in silverlight?

我想在silverlight5页面播放.swf。我正在使用ListBox控件或图像控件或任何想法在Silvarlight中播放swf文件

<Image Grid.Row="0" Name="bottom_video" Height="80" Source="{Binding VodeoUrl,Mode=OneWay}" Margin="0,20,0,0" /> 

You might be able use the the Flash ActiveX control that is automatically installed with the flash player itself on every windows machine but if it works it'd still comes with a lot of limitations as stated here another problem will be the "Airspace" problem .

Another way is to convert the SWF to XAML using this . But I found quite a lot of swf files that couldn't be converted. Especially if there is a lot of ActionScript or dynamic loading of content involved.

You can see in the code below how to use Iframe on Silverlight:

<Grid x:Name="LayoutRoot">

        <HyperlinkButton Content="HyperlinkButton" Height="23" HorizontalAlignment="Left" Margin="44,20,0,0" Name="hyperlinkButton1" VerticalAlignment="Top" Width="100" TargetName="" Click="hyperlinkButton1_Click"  />

    </Grid>



code behind:



private void hyperlinkButton1_Click(object sender, RoutedEventArgs e)        { 



HtmlDocument _document = HtmlPage.Document;


            HtmlElement iframe = _document.CreateElement("IFRAME");
            iframe.SetAttribute("src", "http://localhost:52878/TestForm.aspx");


            iframe.SetStyleAttribute("position", "absolute");
            iframe.SetStyleAttribute("top", "100px");
            iframe.SetStyleAttribute("left", "200px");
            HtmlElement body = (HtmlElement)_document.GetElementsByTagName("BODY")[0];
            body.AppendChild(iframe);

HtmlDocument _document = HtmlPage.Document;

            HtmlElement iframe = _document.CreateElement("IFRAME");

            iframe.SetAttribute("src", "http://localhost:52878/TestForm.aspx");

            iframe.SetStyleAttribute("position", "absolute");

            iframe.SetStyleAttribute("top", "100px");

            iframe.SetStyleAttribute("left", "200px");

            HtmlElement body = (HtmlElement)_document.GetElementsByTagName("BODY")[0];

            body.AppendChild(iframe);

}

我已经得到了如何在Silverlight 5中播放swf文件的答案

 <WebBrowser Grid.Row="1" VerticalAlignment="Top" Source="{Binding VodeoUrl,Mode=OneWay}" Height="280" Width="280"/>

This is impossible. Silverlight does not play swf files. If it is just a video file without any interaction, you might be able to convert the video to something that Silverlight can play. Here is some information about the supported formats:
http://msdn.microsoft.com/en-us/library/cc189080%28v=vs.95%29.aspx

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM