RemoteControls icon indicating copy to clipboard operation
RemoteControls copied to clipboard

Pause button always active on lock screen

Open nigel-dev opened this issue 10 years ago • 2 comments

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

nigel-dev avatar Aug 25 '15 08:08 nigel-dev

Getting the same issue, any way of fixing it?

DahliaWitt avatar Aug 26 '15 00:08 DahliaWitt

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];
                }
            });

sinedied avatar Aug 13 '16 14:08 sinedied