QWebEngineView Stadia game how to captured mouse - qml

Run the Stadia game in QWebEngineView, in the stadia i got a message
it's possible to capture mouse?
here is my code
WebEngineView{
anchors.fill: parent
url: "https://stadia.google.com/"
onFullScreenRequested: function(request) {
request.accept()
}
}

Related

How do I go directly from FullScreen to Maximized in a QML Window?

Below is a small QML application. What I intended was for the application to start full screen, and on the Escape key, change it to maximized:
import QtQuick 2.15
import QtQuick.Window 2.15
Window {
id: topLevelWindow
width: 640
height: 480
visible: true
title: qsTr("Hello World")
visibility: Window.FullScreen
Rectangle {
id: rect
anchors.fill: parent
color: "lightBlue"
focus: true
Keys.onPressed: {
if (event.key === Qt.Key_Escape) {
rect.color = "lightGreen"
topLevelWindow.visibility = Window.Maximized
}
}
}
}
What actually happens, though, is that it starts full screen as intended, but pressing Escape makes it windowed but not maximized. Pressing Escape a second time actually maximizes it.
Is there a way to do this without making the user hit Escape twice?
It looks like this is indeed a bug. Seems like it's been lingering for a while, but (some) newer versions may have fixed it?
In the meantime, it's relatively easy to add a hacky workaround:
import QtQuick 2.15
import QtQuick.Window 2.15
Window {
id: topLevelWindow
width: 640
height: 480
visible: true
title: qsTr("Hello World")
visibility: Window.FullScreen
Rectangle {
id: rect
anchors.fill: parent
color: "lightBlue"
focus: true
Keys.onPressed: {
if (event.key === Qt.Key_Escape) {
rect.color = "lightGreen"
topLevelWindow.visibility = Window.Windowed
windowHackTimer.start()
}
}
}
Timer {
id: windowHackTimer
interval: 0
repeat: false
onTriggered: {
topLevelWindow.visibility = Window.Maximized
}
}
}
On the button press it becomes windowed, and then after it returns to the event loop (with a 0ms timer), it sets it to maximized. Just setting topLevelWindow.visibility multiple times in Keys.onPressed doesn't get the job done.
I think you should (1) make sure that the Escape key is accepted by your event handler (so that it is not passed down) and (2) schedule the outcome with Qt.callLater.
Keys.onPressed: {
if (event.key === Qt.Key_Escape) {
event.accepted = true;
Qt.callLater( greenRectAndMaximize );
}
}
function greenRectAndMaximize() {
rect.color = "lightGreen";
topLevelWindow.visibility = Window.Maximized;
}
The event.accept() is important to ensure that no other UI will handle the same event. That could be the cause of your problem. The Qt.callLater is important because it ensures that your action is added to the end of the windows messaging queue so that the UI/UX for the Escape key (and any other UI/UX events can complete) before we do our action.
Generally, whenever processing events, key presses, button clicks, and so forth, think about what needs to happen now and what needs to be queued for later.
In your case, you have a simple action, but, imagine something more complex such as a button click that triggers a page transition and a sort of 10000 records. The UI/UX is the user clicks the button and we want to see the button animate down and up fully before the action kicks off. If we did it during the event handler, the button may appear to be stuck in the down portion of the animation and the app will appear momentarily hang/crash. So, it is important to understand when we need to queue up actions.
Qt.callLater is one of the easiest ways to separate the UI/UX event and the user action and can improve the perceptual responsiveness of your application.

player position is out of sync audio_service flutter

I have an audioplayer application which uses audio_service and just_audio plugins for playback. Everything seems fine but there are 2 issues that I am facing.
The player position is out of sync, the duration becomes the position but when I pause the audio it reflects the right position. This behaviour can be seen on the notifications and on the AudioService.positionStream which is updating the seek bar on Flutter UI.
Audio stops playing on lock screen out of the blue.
My code:
_playbackSubscription = _player.playbackEventStream.listen((event) {
setState(_player, event);
});
void setState(AudioPlayer _player, event) {
if (queue == null || queue.isEmpty) return;
var controls = [
MediaControl.skipToPrevious,
_player.playing ? MediaControl.pause : MediaControl.play,
MediaControl.skipToNext,
MediaControl.stop
];
AudioServiceBackground.setMediaItem(
queue.elementAt(_player.currentIndex).copyWith(
duration: _player.duration,
));
AudioServiceBackground.setState(
playing: _player.playing,
bufferedPosition: _player.bufferedPosition,
speed: _player.speed,
shuffleMode: _player.shuffleModeEnabled
? AudioServiceShuffleMode.all
: AudioServiceShuffleMode.none,
repeatMode:
AudioServiceRepeatMode.values.elementAt(_player.loopMode.index),
position: _player.position,
processingState: {
ProcessingState.idle: AudioProcessingState.none,
ProcessingState.loading: AudioProcessingState.connecting,
ProcessingState.buffering: AudioProcessingState.buffering,
ProcessingState.ready: AudioProcessingState.ready,
ProcessingState.completed: AudioProcessingState.completed,
}[_player.processingState],
systemActions: [
MediaAction.seekBackward,
MediaAction.seekTo,
MediaAction.seekForward
],
controls: controls,
updateTime: event?.updateTime ?? DateTime.now());
}
Code Block Summary: Basically setting the AudioService state whenever the player state changes.

Quit app after Toast message dissapears

I've found fantastic topic on creation of Qt/QML implementation of Android Toast. I am trying to upgrade it after Toast disappears some signal is emmited - I want to quit simple Qt/QML app. Here is ToastManager:
import QtQuick 2.7
Column
{
id: root
z: Infinity
spacing: 5
anchors.centerIn: parent
signal signalQuitApp;
property var toastComponent
function show(text,
duration)
{
var toast=toastComponent.createObject(root);
toast.selfDestroying=true;
toast.show(text,
duration);
signalQuitApp();
} // show
Component.onCompleted:
{
toastComponent=Qt.createComponent("Toast.qml");
} // Component.onCompleted
} // Column
The result is, if I click some button inside QML application, it quits before Toast animation is over. How do I emit signal AFTER Toast dissapears?
Assuming you are referring to the answer by #ayberk-Özgür you will need to modify Toast.qml to emit the signal when it is done.
id: root
signal toastFinished()
// ...
onRunningChanged:{
if (!running) {
root.toastFinished();
if (selftDestroying)
root.destroy();
}
}
Before you show the toast you connect to that signal
toast.toastFinished.connect(Qt.quit);
toast.show(text, duration);

Where QML camera.videoRecorder.record() save video file by default?

Where QML camera.videoRecorder.record() save video file by default ?
import QtQuick 2.2
import QtMultimedia 5.0
Item {
id:recoder
width:640
height:360
property bool rstat:true
function recordingSt(st)
{
if(st){
camera.videoRecorder.record() ;
st = false;
}else{
camera.videoRecorder.stop() ;
st = true;
}
}
MouseArea
{
anchors.fill: parent
onClicked:recordingSt(rstat)
}
Camera {
id: camera
videoRecorder.audioEncodingMode: CameraRecorder.ConstantBitrateEncoding
videoRecorder.audioBitRate: 48000
videoRecorder.mediaContainer: "mp4"
videoRecorder.frameRate: 25
}
VideoOutput {
source: camera
anchors.fill: parent
focus : visible // to receive focus and capture key events when visible
}
}
I am using Win8 OS have no idea where the video goes and how to set the path for recording . I tried
videoRecorder.outputLocation: "sameDirectory"
still not working why ?
From the documentation, it looks like you can set the location where you want to save by means of the properties imageCapture, which has the method captureToLocation.
It has also a property called capturedImagePath that maybe contains what you are looking for.
Look here and here and here for further details.
Sorry, just seen you were asking for the videoRecording.
It has the actualLocation property as well and it works as above, doesn't it?
The documentation states that that property holds the actual location of the last saved media content. Be aware that it's available once the recording starts, so you should look at it after the record method has been invoked.

Sencha Touch 2 Navigationview pop and push event listener

I have a navigationView with some items on it, if I pop the item, and push a modified one back, the event listeners in my controller no longer trigger. How can I get them to work again? I don't get it because each item destroyed and created from scratch when I push it back. Autodestroy is enabled.
//Add a view
this.view = Ext.create('ec.view.view1')
this.getNavigation().push(this.view);
//Remove a view (or press back in the navigationview)
this.getNavigation().pop();
//Add a fresh view back
this.view = Ext.create('ec.view.view1')
this.getNavigation().push(this.view);
Controller tap handler
refs {
button : '#button'
},
control : {
button : {
tap: 'OnTap'
}
},
OnTap: function() { console.log("Tap") }
With the above, all the events, taps, etc break for the view
I had the same issue, search for loads of forums, lost lots of time, got angry about Sencha support and finally moved the button handler code from the controller back into the view:
xtype: 'button',
text: 'Save',
handler: function(button, event) {
console.log('button pressed');
}
"Dirty", but it works.
I suspect the cause of this behavior is NavigationView.pop() destroying the actual NavigationView, but not it's subordinate objects.