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-09-2012, 12:41 PM   #1 (permalink)
Registered Member
 
Join Date: Feb 2012
Posts: 70
Raggou is on a distinguished road
Default MPMediaItem

the error is at MPMediaItem * item = [self getARandomTrack];
What am in doing wrong?

Code:
-(IBAction)playSong:(id)sender{
    
	
	MPMediaItem * item = [self getARandomTrack];
	MPMediaItemCollection * collection = [[MPMediaItemCollection alloc] initWithItems:[NSArray arrayWithObject:item]];
	
	MPMusicPlayerController *myPlayer = [MPMusicPlayerController applicationMusicPlayer];
	
	[myPlayer setQueueWithItemCollection:collection];
	[collection release];
	[myPlayer play];

	}
	
	[musicPlayer setQueueWithItemCollection:collection];
	[collection release];
	[musicPlayer play];
	
}

-(MPMediaItem*) getARandomTrack
{
	MPMediaQuery *everything = [[MPMediaQuery alloc] init];
	// Get all Media Items into an Array (Fast)
	NSArray *allTracks = [everything items];
	// Check we have enough Tracks for a Random Choice
	if ([allTracks count] < 2)
	{
		return nil;
	}
	// Pick Random Track
	int trackNumber = arc4random() % [allTracks count];
	MPMediaItem *item = [allTracks objectAtIndex:trackNumber];
	// Display and Return
	return item;

}
Raggou is offline   Reply With Quote
Old 02-09-2012, 01:48 PM   #2 (permalink)
Senior Member
iPhone Dev SDK Supporter
 
Join Date: Aug 2008
Location: Memphis, TN, USA
Age: 24
Posts: 3,983
smithdale87 is on a distinguished road
Send a message via AIM to smithdale87
Default

Can you be more specific about "the error" ? Is this a compiler error? If yes, then what does the compiler error message say?
smithdale87 is offline   Reply With Quote
Old 02-09-2012, 03:02 PM   #3 (permalink)
Registered Member
 
Join Date: Feb 2012
Posts: 70
Raggou is on a distinguished road
Default

Quote:
Originally Posted by smithdale87 View Post
Can you be more specific about "the error" ? Is this a compiler error? If yes, then what does the compiler error message say?
file://localhost/Developer/Applications/Music/Music/MusicViewController.m: warning: Semantic Issue: Instance method '-getARandomTrack' not found (return type defaults to 'id')

Any idea?
Raggou is offline   Reply With Quote
Old 02-09-2012, 03:08 PM   #4 (permalink)
Senior Member
iPhone Dev SDK Supporter
 
Join Date: Aug 2008
Location: Memphis, TN, USA
Age: 24
Posts: 3,983
smithdale87 is on a distinguished road
Send a message via AIM to smithdale87
Default

Did you declare getRandomTrack in your .h file?
smithdale87 is offline   Reply With Quote
Old 02-09-2012, 03:15 PM   #5 (permalink)
Registered Member
 
Join Date: Feb 2012
Posts: 70
Raggou is on a distinguished road
Default

Quote:
Originally Posted by smithdale87 View Post
Did you declare getRandomTrack in your .h file?
Wow....I feel stupid. Thankyou very much, I appreciate it(:
Raggou is offline   Reply With Quote
Reply

Bookmarks

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: 389
11 members and 378 guests
chiataytuday, chits12345, fiftysixty, gmarro, KennyChong, kilobytedump, Leslie80, Matrix23, Meoz, ryantcb, Yosh_K
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,670
Threads: 94,121
Posts: 402,903
Top Poster: BrianSlick (7,990)
Welcome to our newest member, Yosh_K
Powered by vBadvanced CMPS v3.1.0

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