Audio in my App, play pause slider

Guys I'm getting errors with incorporating the UISlider into my audio app, any advice would be great, this is my first app and I'm a newbie...

The track plays fine, stops fine but when I try and skip the app crashes out, I'm sure I've missed something out, just need some fresh eyes on the code, hope someone can advise...


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

@interface NoGraceViewController : UIViewController<AVAudioPlayerDelegate> {
    AVAudioPlayer *audioPlayer;
    UISlider *volumeControl;

@property(nonatomic,retain)IBOutlet UISlider *volumeControl;
@property(nonatomic,retain) AVAudioPlayer *audioPlayer;
@property (weak, nonatomic) IBOutlet UITextField *timeLabel;
@property (weak, nonatomic) IBOutlet UISlider *skipSlider;

-(IBAction) nograceButton;






#import "NoGraceViewController.h"

@interface NoGraceViewController ()


@implementation NoGraceViewController
@synthesize skipSlider;
@synthesize timeLabel;

-(IBAction) nograceButton { 
    [[UIApplication sharedApplication] openURL: [NSURL URLWithString:@""]];

@synthesize audioPlayer;

- (IBAction)playbutton
    [audioPlayer play];


    [audioPlayer stop];

- (IBAction)skipSliderMoved:(UISlider *)sender {
    self.audioPlayer.currentTime = self.audioPlayer.duration*sender.value;

- (void)viewDidLoad {
    [super viewDidLoad];
    NSURL *url=[NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"001.mp3" ofType:nil]];

    NSError *error;
    audioPlayer = [[AVAudioPlayer alloc]initWithContentsOfURL:url error:&error];
    if (error)
        NSLog(@"Error in audioPlayer: %@", 
              [error localizedDescription]);
    } else {
        audioPlayer.delegate = self;
        [audioPlayer prepareToPlay];


- (void)viewDidUnload {
    [self setSkipSlider:nil];
    [self setTimeLabel:nil];


-(void)updateDisplay { 
    self.skipSlider.value = self.audioPlayer.currentTime / self.audioPlayer.duration; 
    NSString *timeString = [[NSString alloc] initWithFormat:@"%d:%02d", (int)   self.audioPlayer.currentTime / 60,(int) self.audioPlayer.currentTime % 60];
    self.timeLabel.text = timeString;



Try this:

self.audioPlayer.currentTime = (self.audioPlayer.duration / 100) * sender.value;

Need Your Help

sqoop2 client batch mode script example

cloudera sqoop cloudera-cdh sqoop2

Can anyone show me an example of script that can be run from sqoop2 client in batch mode?

PHP constructor and a bounce of fields dependant on each other

php design-patterns object constructor

MyClass has a bounce of fields, where each value depends on another instance value and, at the end, on a DependencyClass. A very simple example: