I am using Flicker video player to play videos from network in flutter web. When I disable the controls and hide them, it's still working with keyboard shortcuts like m for mute unmute, left right keys for forward and backward. I want to disable these keyboard shortcuts as well. Anybody did this or know about this ? Thanks
Flick Video Player dependency documentation says;
You can pass webKeyDownHandler argument to FlickVideoPlayer and manage the keyboard shortcuts yourself.
Maybe with this parameter you can pass null values to shortcuts and disable them. Check it out.
Tried this code and it works. Thanks to #Slender suggestion.
FlickVideoPlayer(
flickManager: flickManager,
webKeyDownHandler: (event, manager) {
return null;
},
)
Related
i'm making a game on unity and i don't know why but my button "Upgrade" doesn't work, i can't click it, i searched for solutions and here is what i tried :
check if any UI is blocking the way
check if i had "interactable" and "raycast target" activated
check if i had an event system
maybe it is from the physics settings in Edit -> project settings -> physics
because i had to deactivate some things for other stuff, but i think i already tried to reactivate all to see what it did.
https://i.stack.imgur.com/eGhEw.png
here is the project in version 2020.3.33f1 if you want to try something :
https://www.mediafire.com/file/6o17nul40eqtlu9/Mini_RPG.zip/file
I do believe that EventSystem should be outside of Canvas.
It also may be the fact that the button does not have an OnClick event property set, unless you are setting it through code.
I figured it out, you can't put a button on a image (set it as his child), i replaced the image by a pannel and it works.
I'm trying to create a video player with controls for Android TV with Flutter
The basic video_player is working:
https://gist.github.com/andraskende/195e746716e5e4e978356abb09e66a37
Would like to enhance the controls:
video plays: show controls for first 5 seconds, then hide controls..
keypress on D-pad controls would appear (play/pause, forward rewind)
video paused: show controls, if back pressed once hide controls
I tried to add RawKeyboardListener to listen on a keypress on remote but then the controls are not selectable as the RawKeyboardListener takes over..
I guess when the controls are hidden I need RawKeyboardListener to bring up the controls and disable the RawKeyboardListener so the control buttons can be selected.
Any help is greatly appreciated.
Thanks,
Andras
I faced similar kind of issue where I fixed it with below code:
void _onKey(RawKeyEvent e) {
controls();
if (e.runtimeType.toString() == 'RawKeyDownEvent') {
switch (e.logicalKey.debugName) {
case 'Media Play Pause':
case 'Select':
setState(() {
if (_videoViewController.value.isPlaying) {
_videoViewController.pause();
} else {
_videoViewController.play();
}
});
break;
}
}`
Now if you wanted to have a fast forward or back just use the RawKeyboardListener with
specific case to handle it.
You can also use your D-PAD keys to perform such action.
I creating WEB GL game. Game menu is shown by the following code:
Input.GetKeyUp(KeyCode.Escape)
It works fine in unity and in the windows build. In the browser, escape pressing is intercepted by browser and the menu is not displayed.
Is it possible to make this code working in WEB GL build? What is the standart "meny button" for WEB GL games?
It should be working because
From Unity Manual webgl input : By default, Unity WebGL will process all keyboard input send to the page, regardless of whether the WebGL canvas has focus or not.
It could be that you disabled WebGLInput.captureAllKeyboardInput (Which is enabled by default) In that case just enable that and it should work.
The Escape Button is used by default for exiting fullscreen mode, maybe that's causing the issue. I would suggest to use the Input Manager ( https://docs.unity3d.com/Manual/class-InputManager.html ) and define a button using Escape as the positive button.
As #pasotee mentioned, the Escape key could be consumed already. By the Browser, as well as by the Unity Player, as for example the F1 key is used by Chrome to open the Help Tab. Escape is definitely used by the Unity Player to exit its Fullscreen mode.
So the short answer is. No, you can't.
Unity is listening to all key by default, true, but never gets the events when the upper lying application, like the browser, doesn't send it to the Canvas or the executing environment - aka the Unity3d Player doesn't send it down to your code. Or in this case, they should really fix the manual to "[..] all buttons, except Escape and browser related Hotkeys":
https://docs.unity3d.com/Manual/webgl-input.html
The long answer is, you might intercept the 'Escape' key event within JavaScript and pass a function call into the Unity Player like mentioned here:
jQuery
$(document).on('keyup',function(evt) {
if (evt.keyCode == 27) {
alert('Esc key pressed.');
}
});
https://jsfiddle.net/MQHVa/1/
Vanilla JS
var msg = document.getElementById('state-msg');
document.body.addEventListener('keypress', function(e) {
if(e.key == "Escape"){
msg.textContent += 'Escape pressed:'
}
});
https://jsfiddle.net/etcjwaf5/
And in the end you'll need this information, to call Unity from Javascript:
SendMessage('MyGameObject', 'MyFunction');
SendMessage('MyGameObject', 'MyFunction', 5);
SendMessage('MyGameObject', 'MyFunction', 'MyString');
https://docs.unity3d.com/Manual/webgl-interactingwithbrowserscripting.html
And the very last thing is to have a GameObject in your loaded Scene that provides the function for doing, whatever you desired to be done.
Bare in mind, that if you don't cancel distribution of the Escape key event it will be send to the UnityPlayer which triggers it to exit fullscreen mode! And you might not be able to prevent Unity from consuming this event anyway, so remember WebGLInput.captureAllKeyboardInput member.
I'm curious if anyone has found a solution to disabling the default spring-loaded iOS page move when a user drags their finger across the page. For pages that are completely visible (i.e., no scrolling is necessary) the page moves and springs back into place.
I've found that disabling the "touchstart" will effectively fix this, but then it breaks all click events!?! For example:
document.addEventListener('touchstart', function(e) {
e.preventDefault();
}, false);
I've tried other touch / mouse events but no luck. I'm guessing someone out there knows a secret webkit CSS or JavaScript property which can disable this feature.
Edit: as an example of what I'm looking for, here is a similar answer for disabling other default iOS Webkit behaviors via CSS. Unfortunately these don't seem to apply to my question:
Prevent default Press but not default Drag in iOS MobileSafari?
I could have sworn I tried this, but it appears "touchmove" does the trick?
document.addEventListener('touchmove', function(e) {
e.preventDefault();
}, false);
Update: After more testing, yes this does in fact do the trick. It seems as though one should never e.preventDefault() on 'touchstart' as that also prevents all other mouse events that follow.
I want to develop a site which is easy to use from a Playstation 3 PS3 game console web browser. I thought it would be good to make screen actions on button presses on the console.
I can find no information on how to do this after quite a bit of searching.
Any info or links highly appreciated!
Why not write a function that displays a message for every "keystroke" and you'll see what values they represent:
$(document).keypress(function(event) {
alert(event.which);
});
Then you can use the number you get from this test and create some logic based on that.
Like this perhaps:
if(event.which == 13) {
// display cool menu maybe?
}
From what I've tested so far, the left stick generates mouse events, left pad with arrows generates keyboard events corresponding to arrows, while the right stick generates a mouseevent but unfortunately it does not move the mouse, but rather scrolls the window.
I do not know how to detect in which direction the stick is pushed (unless the cursor actually moved or the background scrolled, in which cases it is quite trivial).
Check: http://vanisoft.pl/~lopuszanski/public/ps3/