Xojo Conferences

Platforms to show: All Mac Windows Linux Cross-Platform

/MacFrameworks/WebView Video Render vs Screenshot
Required plugins for this example: MBS MacBase Plugin, MBS MacCocoa Plugin, MBS MacControls Plugin, MBS MacFrameworks Plugin, MBS Main Plugin, MBS Picture Plugin
You find this example project in your Plugins Download as a Xojo project file within the examples folder: /MacFrameworks/WebView Video Render vs Screenshot
This example is the version from Sun, 17th Mar 2012.
Project "WebView Video Render vs Screenshot.rbp"
Class App Inherits Application
Const kEditClear = "&Delete"
Const kFileQuit = "&Quit"
Const kFileQuitShortcut = ""
End Class
Class Window1 Inherits Window
Control c Inherits CocoaControlMBS
ControlInstance c Inherits CocoaControlMBS
EventHandler Function GetView() As NSViewMBS dim html, URL as string URL = "http://realsoftware.cachefly.net/movies/web_intro_en/web_intro-desktop.m4v" html = "<html><head><title>Render Video Content Test</title></head><body><video controls autoplay src='"+URL+"' /></body></html>" v = new WebViewMBS(0,0,me.Width,me.Height) v.autoresizingMask = NSViewMBS.NSViewHeightSizable + NSViewMBS.NSViewWidthSizable v.drawsBackground = true v.Preferences.arePlugInsEnabled = true v.LoadHTMLString(html, URL) Return v End EventHandler
End Control
Control Canvas1 Inherits Canvas
ControlInstance Canvas1 Inherits Canvas
End Control
Control Label1 Inherits Label
ControlInstance Label1 Inherits Label
End Control
Control PushButton1 Inherits PushButton
ControlInstance PushButton1 Inherits PushButton
EventHandler Sub Action() Canvas1.backdrop = GetWebsiteImage(v) End EventHandler
End Control
Control PushButton2 Inherits PushButton
ControlInstance PushButton2 Inherits PushButton
EventHandler Sub Action() Canvas1.backdrop = GetWebViewScreenshot(v) End EventHandler
End Control
Function GetWebViewScreenshot(v as WebViewMBS) As picture dim p as picture = ScreenshotRectMBS(self.left+c.left,self.top+c.top,c.width,c.height) return p End Function
Function GetWebsiteImage(v as WebViewMBS) As picture dim i as NSImageMBS = v.RenderWebsiteImage dim p as picture = i.CopyPictureWithMask return p End Function
Property v As WebViewMBS
End Class
MenuBar MenuBar1
MenuItem FileMenu = "&File"
MenuItem FileQuit = "#App.kFileQuit"
MenuItem EditMenu = "&Edit"
MenuItem EditUndo = "&Undo"
MenuItem UntitledMenu1 = "-"
MenuItem EditCut = "Cu&t"
MenuItem EditCopy = "&Copy"
MenuItem EditPaste = "&Paste"
MenuItem EditClear = "#App.kEditClear"
MenuItem UntitledMenu0 = "-"
MenuItem EditSelectAll = "Select &All"
End MenuBar
End Project

Feedback, Comments & Corrections

The items on this page are in the following plugins: MBS MacFrameworks Plugin.

MBS FileMaker blog