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 04-28-2011, 05:13 AM   #1 (permalink)
Registered Member
 
Join Date: Mar 2011
Location: Chennai, India
Posts: 2
itzmepraveenkumar is on a distinguished road
Default How to create a audioplayer application like pandora app?

I am created an application which play multiple audio files from locally. Audio files are long. Audio player has following options for the user

* Forward,
* Rewind,
* Next Track,
* Previous Track,

I am planning to use AvAudioPlayer so that i can play an audio with long time. When i am changing the audio file ie pressing next track audio. The audioplayer instance is not getting released. This problem is appearing some times only. Please help me..!! I am help less..

Next Track Button IBAction Method

*

(IBAction) nextTrackPressed { [audioPlay stopAudio]; if (audioPlay) { audioPlay = nil; [audioPlay release]; }

appDelegate.trackSelected += 1; [self intiNewAudioFile]; [self play]; }

Initializing audio file through below method

-(void) intiNewAudioFile { NSAutoreleasePool *subPool = [[NSAutoreleasePool alloc] init];

NSString *filePath = [[NSString alloc] init];

trackObject = [appDelegate.trackDetailArray objectAtIndex:appDelegate.trackSelected];
NSLog(@"%@",trackObject.trackName);
// Get the file path to the song to play.
filePath = [[NSBundle mainBundle] pathForResource:trackObject.trackName ofType:@"mp3"];

// Convert the file path to a URL.
NSURL *fileURL = [[NSURL alloc] initFileURLWithPath:filePath];

if (audioPlay) {
audioPlay = nil;
[audioPlay release];
}

audioPlay = [[AudioPlayerClass alloc] init];
[audioPlay initAudioWithUrl:fileURL];

[filePath release];
[fileURL release];
[subPool release];

}

AudioPlayerClass Implementation
import "AudioPlayerClass.h"

@implementation AudioPlayerClass

*

(void) initAudioWithUrl: (NSURL *) url {

curAudioPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL:url error:nil]; [curAudioPlayer setDelegate:self]; [curAudioPlayer prepareToPlay]; }
*

(void) playAudio { [curAudioPlayer play]; }
*

(void) pauseAudio { [curAudioPlayer pause]; }
*

(void) stopAudio { [curAudioPlayer stop]; }
*

(BOOL) isAudioPlaying { return curAudioPlayer.playing; }
*

(void) setAudiowithCurrentTimeNSInteger) time { curAudioPlayer.currentTime = time; }
*

(NSInteger) getAudioFileDuration { return curAudioPlayer.duration; }
*

(NSInteger) getAudioCurrentTime { return curAudioPlayer.currentTime; }
*

(void) releasePlayer { [curAudioPlayer release]; }
*

(void)dealloc { [curAudioPlayer release]; [super dealloc]; }

@end
itzmepraveenkumar is offline   Reply With Quote
Reply

Bookmarks

Tags
iphone & ipod touch apps

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: 340
12 members and 328 guests
dansparrow, iOS.Lover, lorrettaui53, MikaelBartlett, Nobbsy, oztemel, pbart, PlutoPrime, samdanielblr, sledzeppelin, thephotographer, Trickphotostudios
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,663
Threads: 94,120
Posts: 402,898
Top Poster: BrianSlick (7,990)
Welcome to our newest member, LezB44
Powered by vBadvanced CMPS v3.1.0

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