0

我创建了一个 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];

请帮我解决它。

4

1 回答 1

0

改变

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

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

还有查询结果的值是多少

于 2010-11-08T12:09:07.950 回答