Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 02-15-2009, 02:53 PM   #1 (permalink)
Registered Member
 
Join Date: Jan 2009
Posts: 44
ioiiooo is on a distinguished road
Default Restart Sound w/ AVAudioPlayer

If you have a longer sound (say 5-10 sec) that you have play while the screen is touched using AVAudioPlayet, and you let go part way through playback, is there a way on the next touch to have the player start from the beginning of the sound again, rather than from the point where you stopped touching as seems to happen by default?
ioiiooo is offline   Reply With Quote
Old 02-15-2009, 03:36 PM   #2 (permalink)
Registered Member
 
Join Date: Jan 2009
Posts: 255
rpstro02 is on a distinguished road
Default

Quote:
Originally Posted by ioiiooo View Post
If you have a longer sound (say 5-10 sec) that you have play while the screen is touched using AVAudioPlayet, and you let go part way through playback, is there a way on the next touch to have the player start from the beginning of the sound again, rather than from the point where you stopped touching as seems to happen by default?

This will reset the player to the beginning:

[yourAVAudioPlayer setCurrentTime:0.0];
rpstro02 is offline   Reply With Quote
Old 02-15-2009, 05:40 PM   #3 (permalink)
Registered Member
 
Join Date: Jan 2009
Posts: 44
ioiiooo is on a distinguished road
Default

Quote:
Originally Posted by rpstro02 View Post
This will reset the player to the beginning:

[yourAVAudioPlayer setCurrentTime:0.0];
Awesome! Thank you!
ioiiooo is offline   Reply With Quote
Old 08-03-2009, 01:09 PM   #4 (permalink)
Registered Member
 
Join Date: May 2009
Posts: 75
albotrg is on a distinguished road
Default

i need help [AVAudioPlayer setCurrentTime:0.0];

Last edited by albotrg; 08-03-2009 at 01:12 PM.
albotrg is offline   Reply With Quote
Old 08-03-2009, 01:10 PM   #5 (permalink)
Registered Member
 
Join Date: May 2009
Posts: 75
albotrg is on a distinguished road
Default

i need help [AVAudioPlayer setCurrentTime:0.0];

(IBAction)f4 {
NSString *path = [[NSBundle mainBundle] pathForResource:@"gun" ofType:@"wav"];
AVAudioPlayer* theAudio=[[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPathath] error:NULL];
theAudio.delegate = self;

[theAudio play];
[AVAudioPlayer setCurrentTime:0.0];

Last edited by albotrg; 08-03-2009 at 01:12 PM.
albotrg is offline   Reply With Quote
Old 08-03-2009, 01:15 PM   #6 (permalink)
Registered Member
 
Join Date: Jan 2009
Posts: 255
rpstro02 is on a distinguished road
Default

Quote:
Originally Posted by albotrg View Post
i need help [AVAudioPlayer setCurrentTime:0.0];

(IBAction)f4 {
NSString *path = [[NSBundle mainBundle] pathForResource:@"gun" ofType:@"wav"];
AVAudioPlayer* theAudio=[[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPathath] error:NULL];
theAudio.delegate = self;

[theAudio play];
[AVAudioPlayer setCurrentTime:0.0];
Try This if you want to play the file from the beginning.:
Code:
(IBAction)f4 {
NSString *path = [[NSBundle mainBundle] pathForResource:@"gun" ofType:@"wav"];
AVAudioPlayer* theAudio=[[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPathath] error:NULL];
theAudio.delegate = self;

[theAudio setCurrentTime:0.0];
[theAudio play];
You need to call serCurrentTime on your 'theAudio' object. Not on the AVAudioPlayer class.
rpstro02 is offline   Reply With Quote
Old 08-03-2009, 01:27 PM   #7 (permalink)
Registered Member
 
Join Date: May 2009
Posts: 75
albotrg is on a distinguished road
Default

so If i hold down button the sound play
let go button the sound Stop Playing?
albotrg is offline   Reply With Quote
Reply

Bookmarks

Tags
avaudioplayer, restart, sound

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 326
5 members and 321 guests
Anwerbl, guusleijsten, HowEver, LEARN2MAKE, mottdog
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,649
Threads: 94,113
Posts: 402,879
Top Poster: BrianSlick (7,990)
Welcome to our newest member, Anwerbl
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 08:39 PM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0