我有一个嵌入在 html 页面上的 iframe 中的 youtube 视频。我正在尝试使用 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\"));
}
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 的浏览器”
有人遇到这个问题并对解决它有一些想法吗?
注意:我无法控制来自第三方的内容。