我有一個嵌入在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