Flutter Volume Level Change by Button - ios

I am trying to create a radio application via Flutter.
However, I cannot update the slider value when I increase or decrease the volume by iPhone button. I am using volume control and audioplayers packages.

Does this not do what you want: https://pub.dev/packages/volume_control
Found that in 5 seconds of searching pub. Please get to know the resources you have available.

If I understand correctly, the issue is detecting when the physical volume up/down buttons are pressed and updating the slider to match. I would check out hardware_buttons.
You should be able to listen for the button being tapped using something like this (from their example)
StreamSubscription _volumeButtonSubscription;
#override
void initState() {
super.initState();
_volumeButtonSubscription = volumeButtonEvents.listen((VolumeButtonEvent event) {
// do something
// event is either VolumeButtonEvent.VOLUME_UP or VolumeButtonEvent.VOLUME_DOWN
});
}
Then use volume_control to get the current volume
// Get the current volume, min=0, max=1
double _val = await VolumeControl.volume;
And finally call setState to update the slider with the current volume.

Related

Detect when Electron app is moved to different monitor/display

I'm building an Electron app, and the way I have the window sizes configured is to base itself on % of the monitor/display dimension.
However I quickly noticed an issue when the user has more than one monitor. The initial window dimensions are calculated and never re-calculated for when the user changes to the second monitor, and due to this in the case that the monitors aren't the same dimension, the window has the wrong size on the other monitor.
Essentially what I'm looking for here is any sort of event which will detect when the user changes the monitor he/she is using the app on, and in this way I will be able to re-calculate the window size based on the new monitor dimension.
You can use the move event of the BrowserWindow in combination with the screen API like such:
const {app, BrowserWindow} = require("electron");
let mainWindow;
app.on("ready", function() {
mainWindow = new BrowserWindow();
// Screen module must be imported after app is ready (as per docs)
const {screen} = require("electron");
mainWindow.on("move", () => {
const bounds = mainWindow.getBounds();
const currentDisplay = screen.getDisplayNearestPoint({x: bounds.x, y: bounds.y});
// Perform your actions here..
console.log(currentDisplay);
});
});
In the event handler, you can then obtain the display metrics and perform any actions you need based on that.
Note that the move event fires very frequently. You may check out the moved event or implement some form of debouncing yourself if needed.

GWT: Textbox doesn't show Cursor on Ipad

I am trying to implement a Textbox that can show fractions with GWT.
Therefor I have an Canvas were I can draw what I want and receive KeyEvents and MouseEvents.
But on Ipad (Safarie and Chrome) the software keyboard does not show, so I created an Composite and combined the Canvas with a Textbox witch gets the focus after each key or mouse Event on the Canvas.
But the softkeyboard does not show up every time so I tried a bit and can see, that the Textbox seems to get the focus (it gets a blue boarder) but does not always show the cursor.
This does not happen on my Notebook.
Is there any difference between being focused and showing the cursor?
I tried:
Setting the Cursor position
set the Text of the Textbox.
Any help would be appreciated,
Christoph
public void setFocus(boolean b) {
// if (hasFocus) {
Scheduler.get().scheduleDeferred(new ScheduledCommand() {
public void execute () {
t.setFocus(b);
}
});
Scheduler.get().scheduleDeferred(new ScheduledCommand() {
public void execute () {
box.setFocus(true);
box.setText("x");
box.setCursorPos(0);
// box.setVisible(false);
// box.setVisible(true);
}
});
// t.setFocus(b);
// box.setFocus(b);
// }
}
The iOS browsers don't allow the focus to be set programmatically unless directly in response to a user interaction (i.e. a touch). I believe the reason is to prevent websites bringing up the virtual keyboard for no reason.
The downside is that it clobbers setFocus() for websites that want to use it for legitimate reasons. You can't call setFocus() in a deferred command because that doesn't count as a direct response to the user interaction.
(To be more precise, you can call setFocus() in a deferred command, but it won't have the desired effect as you found out.)

How do I change the position in the video in flutter?

I need a way to change the video position programmatically without scrubbing or using the default scrubber. However, the position value is not a setter so how would I be able to do this?
Assuming you're using the VideoPlayerController from the video_player package you can seek to the position you want programmatically by using the seekTo() method.
controller.seekTo(Duration(seconds: /*any second you want*/ ));
To start video where you left off earlier try below code:
controller..initialize().then((_){
setState(() {
controller.play();
controller.seekTo(controller.value.position + lastduration);
});
});
It works for me

Proper way to Update TableView when adding / deleting

I have a list of bluetooth devices that can be turned off and on. When on they appear in the tableview and get removed when turned off. My bluetooth manager object contains the device list and whenever the list is updated a notification is triggered to update the tableview. Adding doesn't seem to be a problem, those appear instantly, but when I remove something from the list it doesn't seem to get removed from the tableview.
Is this expected behavior or does updating the tableview not work with this method?
private void DeviceCollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
{
updateDevices();
}
private void updateDevices()
{
Console.WriteLine("Update in iOS");
deviceTable.Source = new DeviceTableSource(bleHandler.getModelList().ToList());
deviceTable.ReloadData();
}
I know reloading isn't optimal as it redraws the entire table but the list is limited to 6 devices and shouldn't change very often.
Here's how I was able to get it to remove correctly. It came down to a threading issue.
InvokeOnMainThread(() => {
deviceTable.ReloadData();
});

JavaFX8: Application in fullscreen mode doesn't show focus on elements

I have the following problem: I would like to see which textfield or button is focused when I enter my multiscreen application in fullscreen mode. But for some reason, it is not showing the focus "glow" around for example a textfield. This is not a major problem, while it is focused the way I want it (requestFocus() does its job).
But it now gets annoying when I want to use AutoComplete TextField Completion from ControlsFX (How to implement AutoComplete TextField using ControlsFX), because the list is not shown in full screen mode.
I will clarify the situation with these screenshots:
How it is now in fullscreen mode:
How it should be (and how it is in non fullscreen):
To be clear: the problem doesn't only exist with AutoComplete TextField, but with every FXML element.
If I use the fullscreen mode from OSX itself, it works the proper way (It gives an error on the background). But I want the application to start in fullscreen mode.
This the code from my Main.java:
public class Main extends Application {
//Get the screenscontroller instance
octocash.GUI_Screens.ScreensController mainContainer = octocash.GUI_Screens.ScreensController.getInstance();
//Get the configuration instance
Configuration initApp = Configuration.getInstance();
//Create an object of Functions to establish a database connection
public static Functions databaseConnection = new Functions();
//Create a stage object to hold the primarystage
public static Stage primaryStage;
#Override
public void start(Stage stage) throws Exception {
primaryStage = stage; //set the primary stage
databaseConnection.DB_Connect(); //establish database connection
//Load the initial screen (lockscreen)
mainContainer.loadScreen(Configuration.lockScreen, Configuration.lockScreenFile);
mainContainer.setScreen(Configuration.lockScreen);
Group root = new Group(); //Create a group to hold all other screens
root.getChildren().addAll(mainContainer); //Add all Screenscontroller screens to the Group
Scene scene = new Scene(root); //set the group to the scene
stage.getIcons().add(new Image("file:src/octocash/images/octo_cash_logo.png")); //add a menubar icon
stage.setTitle("OctoCash Development"); //set the window name
stage.setScene(scene); //set the scene
stage.setFullScreen(true); //full screen without borders (no program menu bars)
stage.setFullScreenExitHint(""); //Don't show "Press ESC to exit full screen"
//stage.setFullScreenExitKeyCombination(KeyCombination.NO_MATCH); //DO NOT TURN ON UNLESS YOU CREATED ANOTHER METHOD TO EXIT THE PROGRAM
stage.show(); //show the application
}
/**
* #param args the command line arguments
*/
public static void main(String[] args) {
launch(args); // start the application
}
}
As you can see, I am using a ScreensController, which is basically a StackPane with all of the screens in it.
I hope the question is clear to you all.
Any help is greatly appreciated!
I figured out that this is an error in Java JDK 8u25. I have now updated to Java JDK 8u40, and this solves the problem. Also, I have tested the fullscreen focus on Windows and Linux, and there it also works. So if you are having the same problem, just update your JDK.

Resources