0

I had to embed a YouTube video in one of my windows 8 xaml apps. I added an iframe in a webView like this. Now my problem is that when I navigate away from the page the YouTube video continues to play. Since the page in which the WebView is not present in the current view after navigation, I am not able to access the iframe as well. Is there a way to stop the video somehow once I navigate away from the page?

Thanks and Regards, Ramya

Ramya
  • 561
  • 1
  • 4
  • 25

1 Answers1

0

Do you want to pause the video (and cache the page) so they can come back to where they were?

If not, then a less than elegant (but effective) option:

    protected override void OnNavigatingFrom(NavigatingCancelEventArgs e)
    {
        base.OnNavigatingFrom(e);
        wv.NavigateToString("");
    }

If you want to pause the video, I believe you should be able to accomplish that goal by including some JavaScript in the YouTube IFrame API in combination with OnNavigatingFrom and a call to InvokeScript.

Jim O'Neil
  • 23,344
  • 7
  • 42
  • 67