Skip to content
This repository is currently being migrated. It's locked while the migration is in progress.

Fixed & enhanced Now playing info #25

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

username0x0a
Copy link

– added a few other properties so the information is more complete and trackable by remote clients
–– this fixes f.e. Pebble watch Music app so it can properly indicate Play/Pause and playback position
– set to update the Now playing info a bit more often

– added a few other properties so the information is more complete and trackable by remote clients
–– this fixes f.e. Pebble watch Music app so it can properly indicate Play/Pause and playback position
– set to update the Now playing info a bit more often
MPMediaItemPropertyPlaybackDuration: [self.nowPlayingItem valueForProperty:MPMediaItemPropertyPlaybackDuration] ?: @0
MPMediaItemPropertyPlaybackDuration: @(totalInSeconds),
MPNowPlayingInfoPropertyElapsedPlaybackTime: @(elapsedInSeconds),
MPNowPlayingInfoPropertyPlaybackProgress: @(elapsedInSeconds/totalInSeconds),

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There could be a divide by zero risk there, no?

Copy link
Author

@username0x0a username0x0a Feb 21, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, in fact there is none because of how the system behaves, further details here:
http://stackoverflow.com/questions/1449109/why-doesnt-this-crash-arent-i-dividing-by-zero-here

But it definitely is a suspiciously looking operation. I've patched this in the following commit along with a symbol checking for the other properties I've added as these are officially available since SDK 10.0.

There are potentially other places that could cause troubles because of the SDK availability stuff since iOS 7.0 or 9.x so I wouldn't guarantee that this library still works correctly on iOS 5+6 (and maybe even 7+8+9.0) like the Example deployment setting declares.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants