HTML Viewer video playing/stop

I Have the following code to play a video.
When I leave the view I can still hear the video playing in the background.

What do I need to do to stop this?

// Save iframe content as a file
Dim outFile As FolderItem = SpecialFolder.Documents.Child("YouTube.html")
Dim output As TextOutputStream
output = TextOutputStream.Create(outFile, TextEncoding.UTF8)
output.Write(Embed(num))
output.Close

ImageView.Visible = false
HTMLViewer1.Visible = true
// Load the file into the HTMLViewer to display the embedded YouTube video
HTMLViewer1.LoadURL(outFile.URLPath)

You may be better off having the HTMLviewer load some HTML and Javascript to play your video. Then you can control the video using https://documentation.xojo.com/index.php/ExecuteJavaScript

A trivial example:

dim htm as string = "<!DOCTYPE HTML><html><body><video id="video1" src="/path/to/my/video/"></body</html>"
HtmlViewer1.LoadPage(htm, nil)

To play the video:

HtmlViewer1.ExecuteJavascript("var h = document.getElementById('video'1); h.play()' ")

To stop the video

HtmlViewer1.ExecuteJavascript("var h = document.getElementById('video'1); h.pause()' ")

iOSHTMLViewer has no ExecuteJavascript method.

But you might be able to execute javascript like this (untested)

[code]Declare Function jsString lib “UIKit” selector “stringByEvaluatingJavaScriptFromString:” (obj_id as ptr, script as CFStringRef) as CFStringRef

call jsString(iOSHtmlViewer1.handle, “someJavascriptCode”)
[/code]

[quote=391632:@Jeremie Leroy]iOSHTMLViewer has no ExecuteJavascript method.

But you might be able to execute javascript like this (untested)

[code]Declare Function jsString lib “UIKit” selector “stringByEvaluatingJavaScriptFromString:” (obj_id as ptr, script as CFStringRef) as CFStringRef

call jsString(iOSHtmlViewer1.handle, “someJavascriptCode”)
[/code][/quote]
I posted a class once upon a time so you could evaluate JavaScript. It’s still somewhere on the forum I’ll see if I can find it. This definitely should work though

https://forum.xojo.com/19271-ios-what-we-want-roadmap/p2#p169870

https://forum.xojo.com/18429-is-it-possible-to-access-the-contents-of-an-ioshtmlviewer/p1#p154521