Touch Detection in MPVolumeView

I am replicating MPMediaPlayerView using AVPlayer, so I can add some functions to it. I created a play / pause UIView and I show it to the touch and then set a timer to hide it according to the HeadsUpUI sample code. I added MPVolumeView to adjust the volume.

This works just fine, except if you move the volume around, my parental idea has no idea that you are still interacting with the preview and hiding yourself when the timer fires. This way you are still adjusting the volume, but the slider no longer exists.

What I would like to know is when the touch ended in the view and in all the subheadings. Is there any way to do this?

The only solution I can think of is to approach the subviews of MPVolumeView, and when I find the slider, watch the tracking property to see when it will be tracked. But this does not allow someone to hold the button on the button for a long time. I would really like to find a common solution.

TIA

+6
objective-c cocoa-touch uiview avplayer uitouch
source share
1 answer

Add a gesture recognizer to MPVolumeView. Ask the gesture recognizer to call your method, which resets the timer.

MPVolumeView *volumeView = [[MPVolumeView alloc] initWithFrame:CGRectMake(0, 88, 320, 30)]; UIPanGestureRecognizer *recognizer = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(volumeAdjusted:)]; recognizer.cancelsTouchesInView = NO; // this line is VERY important [volumeView addGestureRecognizer:recognizer]; [self.view addSubview:volumeView]; [volumeView release]; -(void)volumeAdjusted:(UIGestureRecognizer *)recognizer { // reset timer } 
+7
source share

All Articles