Is there a way to implement media playback controls on a locked screen notification on Android?
On image below you can see what I mean. It is a VLC notification and even when my phone is locked I can interact with this notification i.e. play/pause the song.
This is my code so far; I took it mostly from JUCE notification examples so it is not yet ready for audio player but it shows the most interesting parts:
PushNotifications::Notification n;
n.identifier = "identifier LSN";
n.title = "title LSN";
n.body = "body LSN";
String prefix;
String extension;
n.icon = prefix + "ic_stat_name2" + extension;
n.publicVersion.reset (new PushNotifications::Notification());
n.publicVersion->identifier = "publicVersion->identifier";
n.publicVersion->title = "publicVersion->title!";
n.publicVersion->body = "publicVersion->body!";
n.publicVersion->icon = n.icon;
int channelID = 1; // 1-high; 2-medium; 3-low importance
n.channelId = String (channelID);
juce::PushNotifications::Notification::Action a1, a2;
a1.style = juce::PushNotifications::Notification::Action::button;
a2.style = juce::PushNotifications::Notification::Action::button;
a1.title = a1.identifier = "Ok";
a2.title = a2.identifier = "Cancel";
a1.triggerInBackground = true;
a2.triggerInBackground = true;
n.actions.add (a1);
n.actions.add (a2);
n.type = juce::PushNotifications::Notification::Type::transport;
n.lockScreenAppearance = juce::PushNotifications::Notification::LockScreenAppearance (1);
PushNotifications::getInstance()->sendLocalNotification (n);
Notification type “transport” seems to be designed for this type of stuff but still I can’t interact with it on locked screen. Any ideas?