C# 在WP7浏览器控件中显示嵌入式视频-已更新

C# 在WP7浏览器控件中显示嵌入式视频-已更新,c#,.net,windows-phone-7,webbrowser-control,embedded-video,C#,.net,Windows Phone 7,Webbrowser Control,Embedded Video,我有一个youtube视频,嵌入在html页面的iframe中。我正在尝试使用wp7应用程序中的web浏览器控件显示此视频(即带有按钮的视频表示,您可以单击该按钮启动默认的wp7视频播放器)。浏览器拒绝使用按钮显示视频。注意:我用不同的嵌入式视频更新了下面的示例代码。测试代码如下所示: private void PageTitle_DoubleTap(object sender, GestureEventArgs e) { string _htmlView = "<html&g

我有一个youtube视频,嵌入在html页面的iframe中。我正在尝试使用wp7应用程序中的web浏览器控件显示此视频(即带有按钮的视频表示,您可以单击该按钮启动默认的wp7视频播放器)。浏览器拒绝使用按钮显示视频。注意:我用不同的嵌入式视频更新了下面的示例代码。测试代码如下所示:

    private void PageTitle_DoubleTap(object sender, GestureEventArgs e)
{
  string _htmlView = "<html><head><style type=\"text/css\">";
  _htmlView += " body { margin: 0; }";
  _htmlView += "</style></head><body>";
  _htmlView += "<iframe height=\"315\" src=\"http://www.youtube.com/embed/0KA4xPUJKtw?rel=0\" frameborder=\"0\" width=\"420\"></iframe>";

  _htmlView += "</body></html>";

  webBrowser.NavigateToString(_htmlView);

  // Navigating directly to the embedded video below does work though
  //webBrowser.Navigate(new Uri("http://www.youtube.com/embed/0KA4xPUJKtw?rel=0\"));

}
private void PageTitle\u双击(对象发送方、GestureEventArgs e)
{
字符串_htmlView=“”;
_htmlView+=“正文{margin:0;}”;
_htmlView+=“”;
_htmlView+=“”;
_htmlView+=“”;
webBrowser.NavigateToString(_htmlView);
//不过,直接导航到下面的嵌入式视频确实有效
//webBrowser.Navigate(新Uri(“http://www.youtube.com/embed/0KA4xPUJKtw?rel=0\"));
}
XAML是

<phone:PhoneApplicationPage 
x:Class="WebTest.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d" d:DesignWidth="480" d:DesignHeight="768"
FontFamily="{StaticResource PhoneFontFamilyNormal}"
FontSize="{StaticResource PhoneFontSizeNormal}"
Foreground="{StaticResource PhoneForegroundBrush}"
SupportedOrientations="Portrait" Orientation="Portrait"
shell:SystemTray.IsVisible="True">

<!--LayoutRoot is the root grid where all page content is placed-->
<Grid x:Name="LayoutRoot" Background="Transparent">
    <Grid.RowDefinitions>
        <RowDefinition Height="Auto"/>
        <RowDefinition Height="*"/>
    </Grid.RowDefinitions>

    <!--TitlePanel contains the name of the application and page title-->
    <StackPanel x:Name="TitlePanel" Grid.Row="0" Margin="12,17,0,28">
        <TextBlock x:Name="ApplicationTitle" Text="MY APPLICATION" Style="{StaticResource PhoneTextNormalStyle}"/>
        <TextBlock x:Name="PageTitle" Text="page name" Margin="9,-7,0,0" Style="{StaticResource PhoneTextTitle1Style}" DoubleTap="PageTitle_DoubleTap"/>
    </StackPanel>

    <!--ContentPanel - place additional content here-->
    <Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
  <phone:WebBrowser x:Name="webBrowser" Margin="0,0,0,0" Width="Auto" IsScriptEnabled="True"/>


</Grid>
</Grid>

我得到“视频播放需要Adobe Flash Player或支持HTML5的浏览器”

有谁遇到这个问题并有一些解决它的想法吗


注意:我无法控制来自第三方的内容

不幸的是,嵌入式浏览器控件的行为与Windows Phone 7上的本机浏览器不同


要为用户可以单击以启动视频的youtube视频创建占位符图像,您需要自己创建(或源)图像。

不幸的是,嵌入式浏览器控件的行为与Windows Phone 7上的本机浏览器不同


要为youtube视频创建一个占位符图像,用户可以单击该图像开始视频,您需要自己创建(或来源)该图像。

经过今天的大量调查,我发现html必须以。添加后,视频将按预期工作。我猜浏览器会对它显示的内容感到困惑。

经过今天的大量调查后,我发现html必须以开头。添加后,视频将按预期工作。我猜浏览器会对显示的内容感到困惑。

哪些内容来自第三方?您不能在WP7上播放嵌入iframe的YouTube视频。你到底想达到什么目的?我应该澄清一下,我不想让它在原地播放视频。在wp7浏览器中,您将获得一个打开“播放”按钮的图像。单击时,它将使用默认的视频播放器播放视频。当我使用浏览器控件查看同一页时,我会看到一个黑框,上面说我需要一个html 5浏览器来显示此内容。哪些内容来自第三方?您不能在WP7上播放嵌入iframe的YouTube视频。你到底想达到什么目的?我应该澄清一下,我不想让它在原地播放视频。在wp7浏览器中,您将获得一个打开“播放”按钮的图像。单击时,它将使用默认的视频播放器播放视频。当我使用浏览器控件查看同一页时,我会看到一个黑框,上面说我需要一个HTML5浏览器来显示此内容。是否使用?只是一个空格或一个点,还是有什么东西丢失了?只是一个空格或一个点或是缺少什么