2010-11-08 116 views
0

我創建了一個iPhone應用程序。使用這個應用程序,我可以錄製我的聲音並能夠播放該錄製的文件。但是如果我從庫中選擇音樂文件,它不會播放。選擇音樂不從iPhone音樂庫中播放

// sample code that I have used in my application 

self.player = [MPMusicPlayerController applicationMusicPlayer]; 
MPMediaPropertyPredicate *songNamePredicate = [MPMediaPropertyPredicate predicateWithValue: self.songName forProperty: MPMediaItemPropertyTitle]; 
MPMediaQuery *mySongQuery = [[MPMediaQuery alloc] init]; 
[mySongQuery addFilterPredicate: songNamePredicate]; 
[player setQueueWithQuery:mySongQuery]; 
[player play]; 

請幫我解決它。

回答

0

變化

MPMediaPropertyPredicate *songNamePredicate = [MPMediaPropertyPredicate predicateWithValue: self.songName forProperty: MPMediaItemPropertyTitle]; 

MPMediaPropertyPredicate *songNamePredicate = [MPMediaPropertyPredicate predicateWithValue:self.songName forProperty:MPMediaItemPropertyTitle comparisonType:MPMediaPredicateComparisonContains]; 

還什麼是查詢結果的值