所选音乐未从iPhone音乐库播放

所选音乐未从iPhone音乐库播放,iphone,mpmusicplayercontroller,Iphone,Mpmusicplayercontroller,我已经创建了一个iPhone应用程序。使用此应用程序,我可以录制我的语音并播放录制的文件。但如果我从库中选择了一个音乐文件,它就不会播放 // sample code that I have used in my application self.player = [MPMusicPlayerController applicationMusicPlayer]; MPMediaPropertyPredicate *songNamePredicate = [MPMediaPropertyPred

我已经创建了一个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];
请帮我解决它。

更改

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

另外,查询结果的值是多少

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