shi11 / RemoteControls

cordova 3 plugin for interacting with ios7 remote controls and metadata
57 stars 41 forks source link

Pause button always active on lock screen #18

Open nigel-dev opened 9 years ago

nigel-dev commented 9 years ago

Using the plugin I am able to get all the play/pause/next/prev functionality on the lock screen and the control center. The issue that I am running into is that on the lock screen it always shows the pause button no mater if it is playing or not.

I am using @ghenry22 media plugin fork (https://github.com/ghenry22/cordova-plugin-media) for the ability to use the AVPlayer to stream mp3's

DahliaWitt commented 9 years ago

Getting the same issue, any way of fixing it?

sinedied commented 8 years ago

The plugin is flawed on this, as it always reports the audio as playing.

My quick fix was to add an extra boolean parameter, to tell if audio is playing or not:

- (void)updateMetas:(CDVInvokedUrlCommand*)command
{
   ...
    NSNumber *isPlaying = [command.arguments objectAtIndex:6];
    ...

                    MPNowPlayingInfoCenter *center = [MPNowPlayingInfoCenter defaultCenter];
                    center.nowPlayingInfo = [NSDictionary dictionaryWithObjectsAndKeys:
                        artist, MPMediaItemPropertyArtist,
                        title, MPMediaItemPropertyTitle,
                        album, MPMediaItemPropertyAlbumTitle,
                        artwork, MPMediaItemPropertyArtwork,
                        duration, MPMediaItemPropertyPlaybackDuration,
                        elapsed, MPNowPlayingInfoPropertyElapsedPlaybackTime,
                        isPlaying, MPNowPlayingInfoPropertyPlaybackRate, nil];
                }
            });