Add MediaService API for volume control and playback management #798
+256
−3
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR exposes the MediaService API to app developers, enabling them to access and control media playback information and volume on connected devices.
Motivation
I'm creating this PR to support enhanced functionality in the Find My Phone app. Currently, when you use the app to locate your phone, there's no way to ensure the device is at an audible volume. By exposing the MediaService API, the app will be able to raise the volume of the device when making it ring, making it much easier to actually find your phone!
More broadly, this opens up a lot of possibilities for app developers to create richer media experiences on Pebble watches.
Changes
SDK Version
New APIs Exposed
MediaService
Provides comprehensive media playback control and information:
Playback Information:
music_get_now_playing()- Get current track title, artist, and albummusic_has_now_playing()- Check if media is currently availablemusic_get_player_name()- Get the name of the active media playermusic_get_pos()- Get current track position and lengthmusic_get_ms_since_pos_last_updated()- Get time since position was last updatedmusic_get_playback_rate_percent()- Get playback speedmusic_get_playback_state()- Get current playback state (playing, paused, etc.)Volume Control:
music_get_volume_percent()- Get current volume levelmusic_is_volume_reporting_supported()- Check if volume reporting is availableCapability Detection:
music_is_playback_state_reporting_supported()music_is_progress_reporting_supported()music_is_command_supported()- Check if specific commands are supportedPlayback Control:
music_command_send()- Send media commands (play, pause, volume up/down, etc.)music_needs_user_to_start_playback_on_phone()- Check if user interaction is neededPerformance:
music_request_reduced_latency()- Request lower latency updatesmusic_request_low_latency_for_period()- Request low latency for a specific durationDebugging:
music_get_connected_server_debug_name()- Get debug information about connected serverEventServiceClient
Added event subscription system for apps to receive media events:
event_service_client_subscribe()- Subscribe to eventsevent_service_client_unsubscribe()- Unsubscribe from eventsPebbleEvent,PebbleEventType,EventServiceEventHandler,EventServiceInfoImplementation Details
music_syscalls.cwith proper privilege checking and buffer validationexported_symbols.jsonfor SDK generationUse Cases
This API enables apps like: