On my Main page I have 3 buttons: play video, play audio, record voice. All these button widgets use Bloc pattern to control its internal state (e.g. changing button Icon when file is playing) but I'm having trouble understanding how to access their states on my Main page because I'd like to disable other buttons when one of them is pressed.
Any recommendation on how to do this?
You can have a global bool variable and can make that variable state to true when any button is pressed, and as soon as your video playback released, you can make that variable to false, and don't forget to make all buttons disable until that variable is true.
Thanks
Related
Is there a way to register multi-touch as a single touch? Say if I use three fingers to tap a large button, can it be registered as simply one tap of the button? -- the current default appears to treat it as a multi-touch, and as a result ignores the button-pressing altogether. Similarly, if I use my palm to tap a large button, the button isn't pressed either.
I noticed in iphone Accessibility Settings -> Touch Accommodations, one could set "Ignore Repeat" and "Use Initial Touch Location" for tap assistance. Of course, if those are turned on, it affects the entire phone instead of just one app. But would that be the direction to approach this problem?
BTW I don't actually need multi-touch in my app. So if turning off multi-touch can be more simply done on the whole-app level instead of button-by-button, it would suit this case very well.
Thank you #DonMag for providing a hint.
So, if yours is an ios app from Capacitor, here is how to change your javascript code:
Change your button onClick events into "onTouchStart"
Use a state variable to keep track of whether "onTouchStart" is triggered and the resulting logic is executing. During that execution, prevent more touch events to have further effect on the button. This is to prevent the button from being pressed in quick succession by multiple touches that come from, say, your three-finger tap or palm tap. Only after the execution is finished do you revert the state variable back to the original value, so that the button is ready to be pressed again.
If there is an answer that's more suitable for the native Swift bundle I'll accept that as the answer. The above is just to help anyone who may encounter the same problem as mine.
Based on the answer from this question, I have implemented an event handler that detects when an AVPlayerItem finishes 'naturally'(through AVPlayerItem.DidPlayToEndTimeNotification) and when it finishes because the user has used the seek bar to reach the end of the video (through AVPlayerItem.TimeJumpedNotification).
I would like to extend this further by checking, in the event handler for the second case, whether the user has stopped seeking - i.e their finger has been lifted from the screen) or whether they're still actively seeking.
Is there any way to detect events on the AVPlayerViewController controls so I can perform this check and react accordingly?
My problem is having several buttons in flash that play sounds when clicked, and I want only one button/sound to be active at a time. Problem is that if the mouse button is released outside of the flash window the last button's sound keeps sounding til the end, and if another button is pressed in the meantime it too starts sounding simultaneously, and so on.
So I thought of checking if the SoundChannel assigned to any other button than the currently pressed one is playing, and if so, stop that SoundChannel to only let the current button's SoundChannel play.
But if this Actionscript SoundChannel is a single object for all the buttons, this won't work, and then I don't see a solution to preventing multiple sounds sounding simultaneously other than adding a 'warning' box, which seems redundant and ineffective. So can you have a separate SoundChannel for each button or object in a flash movie, otherwise how can I bulletproof this so that only one button sound can sound at once no matter where the mouse is released, inside as or outside of the flash window?
Can you put the buttons in a container and addEventListener for MouseEvent.MOUSE_UP and in the handler to check if it cursor is outside the container like so:
private static function onMouseDownOutside(event:MouseEvent) : void {
var mouseDownInsideComponent : Boolean = false;
mouseDownInsideComponent = yourContainer.hitTestPoint(event.stageX, event.stageY, false);
if (!mouseDownInsideComponent) {
//stop the sound
}
}
and just to stop the sound when it gets out of the container? Seems like a possible workaround.
I came to know that iOS does't support widgets this is what i have read.But i am making application on Security in iOS, i want the user to perform some action when he is in need of help without opening the application.
I know iOS supports few background modes like play audio,receive location updates,voip etc.
Can anyone suggest me any alternative to fire some methods without opening the application like pressing some button when in dangerous situation to call those methods.
I don't know whether we can do it or not.
But have a look.
You said we can implement background modes like audio, location, voip updates etc.
Let take the example of Audio mode. It has previous, play/pause, and next button in the lockscreen.
What you can do is play an audio when the application is in background mode.
Check whether the any of the music buttons are pressed more than 3 times. If this is the case trigger alert messages for security and send them to appropriate persons or do your own action.
I don't know whether we can do this or not. Even if it is possible, I can't say Apple will allow such false actions for buttons which are meant for some purpose.
Also see whether we can get detect volume button presses when in background mode. If that is possible you can do that. Because even my LG mobile has an SOS mode which is enabled when I press volume buton in lockscreen 4 times. Apple may allow this action if it possible
I am using AVPlayer to playback a continuous internet radio stream. I set up an AVAudioSession and my Info.plist to continue playback while the app is in background, and handle the remote control events to play, pause and stop.
On iOS there are controls for next and previous track in the multitasking bar, in the lock screen, on connected Bluetooth devices and so on. With these controls available and not "grayed out" the user assumes he could skip to another "track". But this is not possible in my scenario. There are no single "tracks". The app can only consume what is played by the icecast server.
Question: Is it possible to hide or disable these controls, so the user understands that it is not possible to skip to another "track"? (And if yes, how?)
No. Just don't respond to those controls. Respond only to the controls you do respond to (e.g. playpause button).
In this example from one of my apps:
The "next" and "previous" buttons do nothing; they are meaningless. But I've never gotten a complaint from a user.