开发者

Why does my music not play first time?

开发者 https://www.devze.com 2023-02-08 22:01 出处:网络
I have this code: [self.musicPlayer stop]; [self.musicPlayer setQueueWithQuery:persistentQuery]; [self.musicPlayer play];

I have this code:

[self.musicPlayer stop];
[self.musicPlayer setQueueWithQuery:persistentQuery];
[self.musicPlayer play];

But for some reason, you only hear the first split second of a song the first time. Then the second time, you hear the song. Doing a sort of patch-fix with:

[self.musicPlayer stop];
[self.musicPlayer setQueueWithQuery:persistentQuery];
[self.musicPlayer play];
[self.musicPlayer stop];
[self.musicPlayer play];

doesn't work - this only makes it开发者_开发技巧 play the first split second every time.


I had a similar problem in that a MusicPlayer object would not play when the play method was first called. I found I had to setup the musicPlayer object earlier in the app life cycle i.e. set it up before you require it.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号