1

I am creating a non appstore jailbreak tweak and I came across a problem that causes my app to crash.

I am using musicPlayer = [MPMusicPlayerController iPodMusicPlayer];

the music player has complete functionality, play/pause, next, previous. it displays the title of the song, the artist, the artwork and everything.

the problem seems to be the loading and unloading of the musicplayer.

for example, if i am running the app, and i close the iphone's Music app, it will cause my app to crash. also if i load the app without the Music app running in the background it will crash.

as long as the music app is running in the background my app will not crash. can anyone help me with this?

is something to be set to nil? or how do i go about releasing them? should they be synthesize/property?

4

1 に答える 1

0

私は微調整のためにもこの問題を抱えていましたが、それを修正する方法がわかりませんでした。私は AVPlayer メソッドを使用することになりました。それは私にとってはうまくいくようです。確かに私は 1 曲しか再生する必要がないので、何らかのプレイリストを再生する必要がある場合は運が悪いです。

mediapickerclass で次のように使用しました。

NSURL *url = [[mediaItemCollection.items objectAtIndex: 0] valueForProperty:MPMediaItemPropertyAssetURL]
AVPlayerItem *playerItem = [[AVPlayerItem alloc] initWithURL:url];
AVPlayer *player = [[AVPlayer alloc] initWithPlayerItem:playerItem];
[player play];

必要に応じて、別の場所から参照する必要がある場合は、URL を .plist に書き込むだけです。

于 2012-07-21T02:17:13.323 に答える