0

I am building radio APP, I have added UIView to my ViewController and changed its class to MPVolumeView. The slider appears when I test it on my device but is non-responsive to touch gestures. What's weird is that it responds to hardware change with the volume buttons. Here is my code:

#import <UIKit/UIKit.h>
#import <AVFoundation/AVFoundation.h>
#import <MediaPlayer/MediaPlayer.h>


@interface ViewController : UIViewController{
MPVolumeView *_mpVolumeView;
}


 - (IBAction)playPressed:(id)sender;
@property (strong, nonatomic) IBOutlet MPVolumeView *mpVolumeView;

And the m. file:

@interface ViewController ()
 {
AVPlayer *vPlayer;
}
@end

@implementation ViewController
@synthesize mpVolumeView = _mpVolumeView;


- (void)viewDidLoad
{
[super viewDidLoad];

NSURL *vibes = [NSURL URLWithString:@"http://vibesradio.org:8002/listen.pls"];
vPlayer = [[AVPlayer alloc] initWithURL:vibes];

_mpVolumeView.backgroundColor = [UIColor clearColor];
MPVolumeView *myVolumeView = [[MPVolumeView alloc] initWithFrame: _mpVolumeView.bounds];
[_mpVolumeView addSubview:myVolumeView];
}

Thanks for any tips and suggestions to fix this issues. I have spent several hours trying to find a solution without any luck.

Michael Petrotta
  • 59,888
  • 27
  • 145
  • 179
EmilDo
  • 1,177
  • 3
  • 16
  • 33

1 Answers1

0

You may want to change:

MPVolumeView *myVolumeView = [[MPVolumeView alloc] initWithFrame: _mpVolumeView.bounds];
[_mpVolumeView addSubview:myVolumeView];

towards:

self.myVolumeView = [[MPVolumeView alloc] initWithFrame:CGRectZero];
[self.myVolumeView sizeToFit];
[self.view addSubview:self.myVolumeView];
Till
  • 27,559
  • 13
  • 88
  • 122
  • thanks, this worked but adds two sliders - one small to the top of the ViewController and one in the IBOutlet MPVolumeView *mpVolumeView. Did i mess upp with the subviews? self.view – EmilDo Nov 18 '12 at 20:10