Playing Video in WebGadget in Fullscreen
Playing Video in WebGadget in Fullscreen
Hello,
was playing around with the WebGadget and while cruising the internet through the WebGadget, I started a video on youtube and found out that switching to fullscreen doesn't work.
My first thought was that PureBasic's WebGadget implementation might be faulty so I coded a small WebView app in Swift (XCode 7).
However the Swift WebView implementation acts the same way as PureBasic's WebGadget implementation.
(even though all options like javascript are activated)
This means I can't blame the WebGadget but have to blame myself for my ignorance in this matter.
This issue didn't let me go so I started to investigate this.
However, my search in the internet did not reveal any hints on how a WebGadget can be made to recognize a video fullscreen request.
Any hints are truly appreciated.
Thank you
was playing around with the WebGadget and while cruising the internet through the WebGadget, I started a video on youtube and found out that switching to fullscreen doesn't work.
My first thought was that PureBasic's WebGadget implementation might be faulty so I coded a small WebView app in Swift (XCode 7).
However the Swift WebView implementation acts the same way as PureBasic's WebGadget implementation.
(even though all options like javascript are activated)
This means I can't blame the WebGadget but have to blame myself for my ignorance in this matter.
This issue didn't let me go so I started to investigate this.
However, my search in the internet did not reveal any hints on how a WebGadget can be made to recognize a video fullscreen request.
Any hints are truly appreciated.
Thank you
I am to provide the public with beneficial shocks.
Alfred Hitshock
Re: Playing Video in WebGadget in Fullscreen
After some more testing it appears that flash based video streams can be switched to fullscreen.
Therefore the ones that cannot be switched must be html based.
EDIT:
Here a webpage that can be used for html fullscreen switching: http://johndyer.name/lab/fullscreenapi/
Therefore the ones that cannot be switched must be html based.
EDIT:
Here a webpage that can be used for html fullscreen switching: http://johndyer.name/lab/fullscreenapi/
I am to provide the public with beneficial shocks.
Alfred Hitshock
Re: Playing Video in WebGadget in Fullscreen
I can confirm the problem but haven't found a solution yet.
When I googled the problem I noticed there are more people complaining WebView not supporting fullscreen html5 video.
I looked at the class reference https://developer.apple.com/library/mac ... iew_Class/ but so far without any luck.
Making the entire WebView fullscreen is not that difficult but that's not what you are after in this case.
When I googled the problem I noticed there are more people complaining WebView not supporting fullscreen html5 video.
I looked at the class reference https://developer.apple.com/library/mac ... iew_Class/ but so far without any luck.
Making the entire WebView fullscreen is not that difficult but that's not what you are after in this case.
Windows (x64)
Raspberry Pi OS (Arm64)
Raspberry Pi OS (Arm64)
Re: Playing Video in WebGadget in Fullscreen
Thank you for your reply Wilbert.
I'm really puzzled that there is no real information available about this.
Found C code that compiles to a nice small browser and when the video-fullscreen function is activated it really works.
Here is the link: https://github.com/vain/lariza/blob/master/browser.c
Only bummer is it's for Linux not OSX.
Because it's under 1000 lines of code it should be possible to find out what needs to be done in order to get it to work in PureBasic.
Talk to you later...
I'm really puzzled that there is no real information available about this.
Found C code that compiles to a nice small browser and when the video-fullscreen function is activated it really works.
Here is the link: https://github.com/vain/lariza/blob/master/browser.c
Only bummer is it's for Linux not OSX.
Because it's under 1000 lines of code it should be possible to find out what needs to be done in order to get it to work in PureBasic.
Talk to you later...
I am to provide the public with beneficial shocks.
Alfred Hitshock
Re: Playing Video in WebGadget in Fullscreen
After staring long enough at the C code mentioned above the fullscreen switching scenario seems to work like this:
The WebKitWebView events "button-press-event" and "mouse-target-changed" need to be registered.
The "mouse-target-changed" tells the app which element (inside the webview area) is under the mouse cursor.
The "button-press-event" tells the app if a button event (inside the webview area) happened.
So every time the "mouse-target-changed" event occurred, the html link of this element (if available) is stored.
If the "button-press-event" event occurred, the stored link is grabbed and started.
Therefore (I suppose) the html page of that link requests a "fullscreen".
Hope I'm not too far off...
BTW: started testing the "button-press-event" and "mouse-target-changed" events under Linux, but the "mouse-target-changed" event is not recognized even though the C code mentioned above compiles without any warnings in this regard.
There is always something in the way...
The WebKitWebView events "button-press-event" and "mouse-target-changed" need to be registered.
The "mouse-target-changed" tells the app which element (inside the webview area) is under the mouse cursor.
The "button-press-event" tells the app if a button event (inside the webview area) happened.
So every time the "mouse-target-changed" event occurred, the html link of this element (if available) is stored.
If the "button-press-event" event occurred, the stored link is grabbed and started.
Therefore (I suppose) the html page of that link requests a "fullscreen".
Hope I'm not too far off...
BTW: started testing the "button-press-event" and "mouse-target-changed" events under Linux, but the "mouse-target-changed" event is not recognized even though the C code mentioned above compiles without any warnings in this regard.
There is always something in the way...
I am to provide the public with beneficial shocks.
Alfred Hitshock
Re: Playing Video in WebGadget in Fullscreen
It appears webkitRequestFullScreen() isn't supported correctly; don't know if it is possible to add support for it.
Windows (x64)
Raspberry Pi OS (Arm64)
Raspberry Pi OS (Arm64)
Re: Playing Video in WebGadget in Fullscreen
Found this in our Linux forum: http://www.purebasic.fr/english/viewtop ... 15&t=60875 and thought why not.
So tried the code out on Linux and it works,
On Linux youtube videos can be switched to fullscreen.
This means that at least on Linux javaScript was not activated.
This being said under Linux such code would suffice in order to make videos go to fullscreen:
Wondering if on OSX it's the same issue...
However in my Swift code under XCode I switched on JavaScript and it doesn't work either.
Weird.
So tried the code out on Linux and it works,
On Linux youtube videos can be switched to fullscreen.
This means that at least on Linux javaScript was not activated.
This being said under Linux such code would suffice in order to make videos go to fullscreen:
Code: Select all
ImportC ""
g_object_set(*Object.GObject, PropertyName.P-UTF8, *PropertyValue.GValue, Null.b)
EndImport
ImportC "-lwebkitgtk-1.0" ;can be changed with ImportC "-lwebkitgtk-3.0" and gtk3 subsystem
webkit_web_settings_new()
webkit_web_view_set_settings(*WebkitWebView, *WebkitSettings)
EndImport
Procedure EnableWebScripts(gadget)
Protected WebkitSettings.i
WebkitSettings = webkit_web_settings_new()
g_object_set(WebkitSettings, "enable-scripts", #True, #Null)
webkit_web_view_set_settings (GadgetID(gadget), WebkitSettings)
EndProcedure
; and in the main code after creating the webgadget...
EnableWebScripts(gadget_id)
However in my Swift code under XCode I switched on JavaScript and it doesn't work either.
Weird.
I am to provide the public with beneficial shocks.
Alfred Hitshock
Re: Playing Video in WebGadget in Fullscreen
This seems to work on OSX 10.11 but I don't know if it works on older OSX versions and it might be a private method.
Maybe someone can check ?
Maybe someone can check ?
Code: Select all
OpenWindow(0, 0, 0, 800, 500, "WebGadget FullScreenEnabled", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
WebGadget(0, 5, 5, 790, 490, "http://www.youtube.com")
CocoaMessage(0, CocoaMessage(0, GadgetID(0), "preferences"), "setFullScreenEnabled:", #YES)
Repeat
Until WaitWindowEvent() = #PB_Event_CloseWindow
Last edited by wilbert on Sun Nov 29, 2015 6:48 pm, edited 1 time in total.
Windows (x64)
Raspberry Pi OS (Arm64)
Raspberry Pi OS (Arm64)
Re: Playing Video in WebGadget in Fullscreen
It seems you also need Safari 5.1 or newer installed but I believe OSX 10.7 already has this.Wolfram wrote:This works not on 10.7.
Does this work ?
Code: Select all
CocoaMessage(0, CocoaMessage(0, 0, "NSUserDefaults standardUserDefaults"), "setBool:", #YES, "forKey:$", @"WebKitFullScreenEnabled")
OpenWindow(0, 0, 0, 800, 500, "WebGadget FullScreenEnabled", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
WebGadget(0, 5, 5, 790, 490, "http://www.youtube.com")
Repeat
Until WaitWindowEvent() = #PB_Event_CloseWindow
Windows (x64)
Raspberry Pi OS (Arm64)
Raspberry Pi OS (Arm64)
Re: Playing Video in WebGadget in Fullscreen
Hi Wilbert,
no this works also not on 10.7.
I also could not find any information on the Apple page. Do you have any link?
no this works also not on 10.7.
I also could not find any information on the Apple page. Do you have any link?
macOS Catalina 10.15.7
Re: Playing Video in WebGadget in Fullscreen
I don't have an Apple specific page but on this Wikipedia page it's also mentioned (features Safari 5.1)Wolfram wrote:I also could not find any information on the Apple page. Do you have any link?
https://en.wikipedia.org/wiki/Safari_version_history
Does fullscreen html5 work with Safari on your OSX 10.7 ?
And how about the "Simple Demo" and "Video Demo" examples on the page from John Dyer. Do those work ?
Code: Select all
OpenWindow(0, 0, 0, 800, 500, "WebGadget FullScreenEnabled", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
WebGadget(0, 5, 5, 790, 490, "http://johndyer.name/native-fullscreen-javascript-api-plus-jquery-plugin/")
preferences = CocoaMessage(0, GadgetID(0), "preferences")
CocoaMessage(0, preferences, "setJavaScriptEnabled:", #YES)
CocoaMessage(0, preferences, "setFullScreenEnabled:", #YES)
Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
Code: Select all
standardUserDefaults = CocoaMessage(0, 0, "NSUserDefaults standardUserDefaults")
CocoaMessage(0, standardUserDefaults, "setBool:", #YES, "forKey:$", @"WebKitJavaScriptEnabled")
CocoaMessage(0, standardUserDefaults, "setBool:", #YES, "forKey:$", @"WebKitFullScreenEnabled")
OpenWindow(0, 0, 0, 800, 500, "WebGadget FullScreenEnabled", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
WebGadget(0, 5, 5, 790, 490, "http://johndyer.name/native-fullscreen-javascript-api-plus-jquery-plugin/")
Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
Windows (x64)
Raspberry Pi OS (Arm64)
Raspberry Pi OS (Arm64)
Re: Playing Video in WebGadget in Fullscreen
I have done tests with Wilbert's 4 last code examples on these 4 OS X versions with PB 5.40 x86:
- 10.6.8 (Snow Leopard, Safari 5.1.10): the last two code examples switch to fullscreen (in both "Simple demo" and "Video demo"), the other two code examples don't switch to full screen and the info "Vollbild ist nicht verfügbar" (full screen is not available) is displayed above the disabled fullscreen icon after trying to click onto it
- 10.7.5 (Lion, Safari 6.1.6): the last two code examples switch to fullscreen (in both "Simple demo" and "Video demo"), the other two code examples terminate after a few seconds with an invalid memory access error (PB 5.40 x86) or don't switch to full screen and the info "Vollbild ist nicht verfügbar" (full screen is not available) is displayed above the disabled fullscreen icon after trying to click onto it (PB 5.40 x64)
- 10.9.5 (Mavericks, Safari 9.0.1): all 4 code examples allow switching to full screen
- 10.11.1 (El Capitan): all 4 code examples allow switching to full screen
- 10.6.8 (Snow Leopard, Safari 5.1.10): the last two code examples switch to fullscreen (in both "Simple demo" and "Video demo"), the other two code examples don't switch to full screen and the info "Vollbild ist nicht verfügbar" (full screen is not available) is displayed above the disabled fullscreen icon after trying to click onto it
- 10.7.5 (Lion, Safari 6.1.6): the last two code examples switch to fullscreen (in both "Simple demo" and "Video demo"), the other two code examples terminate after a few seconds with an invalid memory access error (PB 5.40 x86) or don't switch to full screen and the info "Vollbild ist nicht verfügbar" (full screen is not available) is displayed above the disabled fullscreen icon after trying to click onto it (PB 5.40 x64)
- 10.9.5 (Mavericks, Safari 9.0.1): all 4 code examples allow switching to full screen
- 10.11.1 (El Capitan): all 4 code examples allow switching to full screen
Last edited by Shardik on Thu Dec 03, 2015 8:52 pm, edited 1 time in total.
Re: Playing Video in WebGadget in Fullscreen
Thank you very much for testing Shardik !
Based on your tests, I think it would be safest to use the approach with standardUserDefaults since it doesn't use any private methods.
I also enabled javascript in the last two code examples so it might be possible YouTube fullscreen will also work with that approach on OSX 10.6.8 .
Could you try that one also ? (this code on OSX 10.6.8 )
In the same way you can also enable WebAudioMy favorite is the "Visualizer" example.
These WebAudio examples work well on OSX 10.11 ; should work on OSX 10.10 I believe and might work on OSX 10.9 depending on what version of Safari is installed.
Based on your tests, I think it would be safest to use the approach with standardUserDefaults since it doesn't use any private methods.
I also enabled javascript in the last two code examples so it might be possible YouTube fullscreen will also work with that approach on OSX 10.6.8 .
Could you try that one also ? (this code on OSX 10.6.8 )
Code: Select all
standardUserDefaults = CocoaMessage(0, 0, "NSUserDefaults standardUserDefaults")
CocoaMessage(0, standardUserDefaults, "setBool:", #YES, "forKey:$", @"WebKitJavaScriptEnabled")
CocoaMessage(0, standardUserDefaults, "setBool:", #YES, "forKey:$", @"WebKitFullScreenEnabled")
OpenWindow(0, 0, 0, 800, 500, "WebGadget FullScreenEnabled", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
WebGadget(0, 5, 5, 790, 490, "http://www.youtube.com")
Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
Code: Select all
standardUserDefaults = CocoaMessage(0, 0, "NSUserDefaults standardUserDefaults")
CocoaMessage(0, standardUserDefaults, "setBool:", #YES, "forKey:$", @"WebKitJavaScriptEnabled")
CocoaMessage(0, standardUserDefaults, "setBool:", #YES, "forKey:$", @"WebKitFullScreenEnabled")
CocoaMessage(0, standardUserDefaults, "setBool:", #YES, "forKey:$", @"WebKitWebAudioEnabled")
OpenWindow(0, 0, 0, 800, 500, "WebGadget FullScreenEnabled", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
WebGadget(0, 5, 5, 790, 490, "http://webaudioapi.com/samples/")
Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
These WebAudio examples work well on OSX 10.11 ; should work on OSX 10.10 I believe and might work on OSX 10.9 depending on what version of Safari is installed.
Windows (x64)
Raspberry Pi OS (Arm64)
Raspberry Pi OS (Arm64)
Re: Playing Video in WebGadget in Fullscreen
No, unfortunately it does not work on OS X 10.6.8 (Snow Leopard) with Safari 5.1.10 and the second example with Web Audio API doesn't work neither.wilbert wrote:I also enabled javascript in the last two code examples so it might be possible YouTube fullscreen will also work with that approach on OSX 10.6.8 .
Could you try that one also ? (this code on OSX 10.6.8 )
But your new examples both work on OS X 10.9.5 (Mavericks) with Safari 9.0.1...