我有一个嵌入在html页面上的iframe中的YouTube视频。我正尝试使用WP7应用程序中的网络浏览器控件来显示此视频(即带有可用于点击以启动默认wp7视频播放器的按钮的视频表示)。浏览器拒绝使用按钮显示视频。注意:我使用不同的嵌入式视频更新了以下示例代码。测试代码如下所示:在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的浏览器才能播放视频”
有人遇到这个问题,并有解决它的一些想法?
注意:我无法控制来自第三方的内容。
哪些内容来自第三方?您无法播放WP7中嵌入在iframe中的YouTube视频。你究竟在努力实现什么? – 2013-02-13 12:37:01
我应该澄清一点,我不希望它实际播放视频。在wp7浏览器中,您会看到一个带有播放按钮的图像。点击时,它使用默认的视频播放器播放视频。当我使用浏览器控件查看同一页面时,我收到一个黑匣子,说我需要一个HTML 5浏览器来显示此内容。 – AndrewJE 2013-02-13 13:10:35