avaudioplayer - Trim the audiofile by selecting point in UISlider -
i working on audioplayer need show progress of audio being played . need trim audio selecting point marked .
thanks,
venkateshwaran
finally found solution
enter code here uislider *sliderprogress = [[uislider alloc] initwithframe:cgrectmake(135, 165, 260, 28)]; sliderprogress.maximumvalue = self.player.duration; [sliderprogress addtarget:self action:@selector(sliderchanged:) forcontrolevents:uicontroleventvaluechanged]; [self setprogressslider:sliderprogress]; [self addsubview:progressslider]; [sliderprogress release]; _leftthumbview = [[uiimageview alloc] initwithframe:cgrectmake(0, 0, 56, 35)]; _leftthumbview.image = [uiimage imagenamed:@"top.png"]; _leftthumbview.contentmode = uiviewcontentmodeleft; _leftthumbview.userinteractionenabled = yes; _leftthumbview.clipstobounds = yes; [progressslider addsubview:_leftthumbview]; uipangesturerecognizer *leftpan = [[uipangesturerecognizer alloc] initwithtarget:self action:@selector(handleleftpan:)]; [_leftthumbview addgesturerecognizer:leftpan]; _rightthumbview = [[uiimageview alloc] initwithframe:cgrectmake(0, 0, 56, 35)]; _rightthumbview.image = [uiimage imagenamed:@"bottom.png"]; _rightthumbview.contentmode = uiviewcontentmoderight; _rightthumbview.userinteractionenabled = yes; _rightthumbview.clipstobounds = yes; [progressslider addsubview:_rightthumbview]; uipangesturerecognizer *rightpan = [[uipangesturerecognizer alloc] initwithtarget:self action:@selector(handlerightpan:)]; [_rightthumbview addgesturerecognizer:rightpan]; - (void)handleleftpan:(uipangesturerecognizer *)gesture { if (gesture.state == uigesturerecognizerstatebegan || gesture.state == uigesturerecognizerstatechanged) { cgpoint translation = [gesture translationinview:self]; cgfloat range = progressslider.maximumvalue - progressslider.minimumvalue; cgfloat availablewidth = 260 - 28; _leftvalue += translation.x / availablewidth * range; if (_leftvalue < 0) _leftvalue = progressslider.minimumvalue; if (_rightvalue - _leftvalue < progressslider.minimumvalue) _leftvalue = _rightvalue - 1.0; [gesture settranslation:cgpointzero inview:self]; [self setneedslayout]; } //if (gesture.state == uigesturerecognizerstateended) //[self hidepopover:_leftpopover];
}
- (void)handlerightpan:(uipangesturerecognizer *)gesture { if (gesture.state == uigesturerecognizerstatebegan || gesture.state == uigesturerecognizerstatechanged) { cgpoint translation = [gesture translationinview:self]; cgfloat range = progressslider.maximumvalue - progressslider.minimumvalue; cgfloat availablewidth = 260 - 28; _rightvalue += translation.x / availablewidth * range; if (_rightvalue > progressslider.maximumvalue) _rightvalue = progressslider.maximumvalue; if (_rightvalue - _leftvalue < progressslider.minimumvalue) _rightvalue = _leftvalue + 1.0; [gesture settranslation:cgpointzero inview:self]; [self setneedslayout];
}
Comments
Post a Comment