this is more so a question asking about how to approach a problem vs me posting code and asking where the error is.
But I am building a paging system in flutter (to work on both android and ios). As a result, I am using custom sounds in my application (so that I can have sounds stronger than the default OS sound). Because this sounds are naturally louder, I want to give the user the option to control the sound level of the notification (from 0 to 100%). I cannot seem to find any resources that speak on this, but I do know it is possible because I have apps on my phone that allow that (amazon pager app for instance).
Is there a way to allow a user control the volume level of a notification through the app that was built in flutter? If it's possible, could i get pointed to a tutorial or article or even sample code?
There's no dedicated way to do this but here's a hack to achieve this. You can use any package/widget of your choice like volume_control or volume_controller
Assuming that you use the first option:
Get the system volume by using
VolumeControl.volume
Get user desired volume level values(Using a slider etc).
Save both values.
Now here you need to set the device notifications/system volume to the user defined values before the notification is played by using
VolumeControl.setVolume(val)
After notification has been played, set the system volume back to the original/previous value.
Same way you can use other widgets.
I tried to do something similar recently and I used this package. It's well documented and there's some sample code for regulating the volume. I used other packages but none work so well as this one.
You can set the volume with something like this:
late AudioManager audioManager;
dynamic maxVol,
currentVol; // Value will be int type on Android device and double type on iOS device
void setVol({int androidVol = 0, double iOSVol = 0.0}) async {
await Volume.setVol(
androidVol: androidVol,
iOSVol: iOSVol,
showVolumeUI: false,
);
}
And then just call the method where you need it and pass the values when changed (in a slider for example).
Hope this helps!
Related
For my personal use only !!!
I am trying to find where I can change the system volume inside an app. I just want to make something that when I press a button it turns down the brightness and lowers the volume (ringtone) and when I am in a meeting I can set a different "profile".
I would use this a lot since I am in classes and meetings during the day.
Any help? I have heard about the celestial framework, but I can't find it anywhere. Is that what i need.
Again, this is not for apple's approval:-) Thanks in advance.
For the brightness you can use following code (and it's even public)
[[UIScreen mainScreen] setBrightness: brightness];
where brightness is some float from 0.0 to 1.0.
For the volume. Try following (these are private APIs in SpringboardService framework)
mach_port_t SBSSpringBoardServerPort();
void SBSetMediaVolume(mach_port_t port, int volume);
In the case, if it won't work. You can try to use GSEvent with code kGSEventVolumeDownButtonDown, kGSEventVolumeDownButtonUp, kGSEventVolumeUpButtonDown, kGSEventVolumeUpButtonUp
The reference implementation is here:
http://code.google.com/p/hid-support/source/browse/trunk/hidspringboard/Tweak.xm?spec=svn82&r=82
It's jailbreak tweak. However, you can extract the code and it should work on non jailbroken phone.
I have seen some apps where when you launch them for the first time after downloading (e.g. Chrome app on iPhone), it shows you a list of animated gestures on the screen, kind of giving you a tour of the app.
How do I build one something like that? And how does the app know to launch only for the first time after download and not since then? For the second question, I am guessing a "shown=TRUE" value can be saved inside a PList file and checking the value each time when the app finished launching. But I am more curious about the mechanism involved in creating a guided app tour.
You can use transparent and semi-transparent images with a UIImageView, so you can make up an image with arrows and notes and put over the whole screen. You could fade it out when the user taps.
To know if it's the first time running the app, you should use NSUserDefaults instead of a plist; it's much easier, and you should be app to find a quick tutorial on that fairly easily.
Also, you could check around on this site for controls like this one. I haven't used any of them myself, so I'm not sure how much they differ from a regular UIImageView. They look nice though.
Im using ZXing, is working fine on my new app, but i would like to integrate the option of front or rear camera,
so far the only reference to this i've found is on the google group
But is not very clear what they mean with that,
so any pointers on what i have to do to accomplish this?
thanks !
ZXWidgetController doesn't provide that functionality and it's not really set up to make it easy to change.
The code that needs to change is in - (void)initCapture. It calls [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo]. This returns the default camera and you don't want the defalt.
You need code similar to that in - (ZXCaptureDevice*)device in ZXCapture.mm. That code won't work out of the box (it's designed to work with both AVFF and QTKit) but it's the same idea. Instead of using the default video input device, go through the devices and look at device position to find the device you want.
Be nice to port that code to the widget but that hasn't happened at this point.
It seems like the built in UIImagePickerController cannot accept sources other than its device camera Roll.
I would like to get the functionality of picking and enlarging pictures within my own app. Also I would like to allow the user to select the pictures and save it into their camera roll (so they can later use it as wall paper)
1) what is the recommended way of building a custom UIImagePickerController that supports what I need ? Is there another built in controller I am missing?
3) Is there a way to take a UIImage and save it to the desktop background of the device directly? Or is it a two step (first save to camera roll), then have the user load the picture from there to save as wallpaper
Thanks in advance!!
At this point, it seems that the only way to build a custom UIImagePickerController functionality is to subclass, and then muck with the view hierarchy directly. This allows you to move, hide, and replace UI elements and access the non-public classes that control the operation of the camera, but as you probably gather, this technique is both unsupported (in that it may, and probably will, break with future updates) and not recommended (in that it may, and probably will, get your app rejected from the App Store if detected).
As far as your second point (somehow numbered 3), John is right: there is no call in the public SDK to accomplish this. You could probably hack something together if you're clever, but remember the warnings in my first paragraph...
Regarding #3) there is no public call in the SDK to save an UIImage to the desktop.
I don't know about the rest of your questions though.
Just today I started a open source UIImagePickerController clone, it is not perfect but it works quite ok. Feel free to fork http://github.com/jeena/JPImagePickerController
I'm working on an iphone application (not web app) and I'd like to build a form asking a user to indicate a price range. Instead of using two text fields, I would prefer to use a double slider to set the minimum and the maximum price. I know that it is possible de use a simple slider (sound control for exemple) but i've never seen a double one. Can anyone help ?
This is not possible without creating a custom control. You'll need to inherit from UIControl or UIView and provide a custom drawRect method. You'll also need to respond to touch and drag events to update the state of the control. I have not done this myself, but I would be prepared for a fairly significant amount of work to get everything to respond and display as expected.
I'm curious as to why you need to have both values specified on a single slider? Why not use two sliders either side-by-side or stacked? It would not require any more input steps than a double slider, and would conform more to standard UI guidelines.
I think you can specify multiple thumbs for a single slider if you subclass UISlider, at least I vaguely remember that being possible in MacOSX. But Code Addict is right, you'll probably be better off using the standard controls - a double-thumbed slider seems like it'd be pretty difficult to deal with in the touchscreen environment.
I built such a control and added it to GitHub so feel free to have a look and if you like the control extend it and contribute.
GitHub page: http://github.com/doukasd/DoubleSlider
Blog post (showing a video of how it works): http://dev.doukasd.com/2010/08/double-slider/