Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial
bader alhawil
iOS Development Techdegree Student 61 PointsI want to complete the music how it is operated from the list
Hello I want to supplement lesson It is not is not fully completed it how is that ? I want to complete the music how it is operated from the list https://teamtreehouse.com/library/build-a-playlist-browser-with-objectivec
1 Answer
Stephen Wall
Courses Plus Student 27,294 PointsI found this on stack overflow to create background music in your app: http://stackoverflow.com/questions/7619794/play-music-in-the-background-using-avaudioplayer
- (void)viewDidLoad
{
NSURL *url = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"in-the-storm" ofType:@"mp3"]];
AVAudioPlayer *audioPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL:url error:nil];
[[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayback error:nil];
[[AVAudioSession sharedInstance] setActive: YES error: nil];
[[UIApplication sharedApplication] beginReceivingRemoteControlEvents];
[audioPlayer play];
[super viewDidLoad];
}
This will have a song playing in the background when a view is loaded. Maybe try and take this same concept and add it to the artist titles so that when they are clicked, the playback will begin. You will obviously need to store the tracks as well. Don't be afraid to google! Stack Overflow is a fantastic resource for when you get stuck.