选定的音乐未从 iPhone 音乐库中播放

发布于 2024-10-01 11:31:35 字数 545 浏览 0 评论 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];

请帮我解决它。

I have created an iPhone application. Using this application, I can able to record my voice and able to play that recorded file. But if I select a music file from library, it is not playing.

// 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];

Please help me to resolve it.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

孤凫 2024-10-08 11:31:35

改成

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

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

查询结果的值是多少

Change

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

to

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

also what is the value of the query result

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文