I
I
Ivan Somov2013-12-17 15:19:08
Objective-C
Ivan Somov, 2013-12-17 15:19:08

Why does playbackState always return 0 (iOs+html5+phonegap)?

I am writing on phonegap (implemented through a plugin), I need to implement a poll for audio playback buttons for iOs in a locked mode.
I'm trying to get the statuses of MPMusicPlayerController:

MPMusicPlaybackState playbackState = [[MPMusicPlayerController applicationMusicPlayer] playbackState];

if (playbackState == MPMusicPlaybackStateStopped || playbackState == MPMusicPlaybackStatePaused) {
    // код если остановлен
} else if (playbackState == MPMusicPlaybackStatePlaying) {
    // код если играет
}

The problem is that the playbackState doesn't change, it's always 0;
It turns out to control the volume through MPMusicPlayerController, according to @mezhevikin's hint , everything works fine. Any way to recognize playback stop is suitable for me, if there are any, tell me, I tried AVAudioSession, but I did not find the parameters there by which it could be tracked.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question