在Windows Metro App 8.1的“后退"按钮上停止YouTube视频 [英] Stop YouTube Video on Back Button of Windows Metro App 8.1
问题描述
我有一个页面,在该页面上我将多个youtube视频显示为网络视图.当我播放任何视频时,相应的视频就会开始播放.但是,当我单击应用程序的后退按钮时,我应该停下来,但它在后台运行(可以听到视频的声音).
I have a page on which i am showing multiple youtube videos as webviews. When i play any video, then correspoding video starts playing. But When I click on the back button of the App i should be stop then but its running in background(can hear voice of video).
这是返回按钮的代码:
protected void GoBack(object sender, RoutedEventArgs e)
{
((Frame)Window.Current.Content).GoBack();
}
告诉我如何处理此网络视图或停止视频.
Tell me how i can dispose of this webview or can stop video.
谢谢
推荐答案
以下是解决方案: 调用WebView的UnLoaded事件 -webView.Unloaded + = webView_UnLoaded;
Here is the solution: Invoke the UnLoaded event of WebView - webView.Unloaded += webView_UnLoaded;
然后在webView_UnLoaded事件处理程序中更改Webview的源: 这是我的代码:
Then change the source of the webview in webView_UnLoaded event handler: Here is my code:
private void webView_UnLoaded(object sender, RoutedEventArgs e)
{
WebView webView = (WebView)sender;
webView.Source = new Uri(" ");
}
这篇关于在Windows Metro App 8.1的“后退"按钮上停止YouTube视频的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!