System Media Control package is a Flutter package that allows you to control the media on the system.
currently available for Android only
To use this plugin, add system_media_controller as a dependency in your pubspec.yaml file.
Examples:
you can control current system media.
final _systemMediaController = SystemMediaController();
_systemMediaController.play();
_systemMediaController.pause();
_systemMediaController.skipNext();
_systemMediaController.skipPrevious();
_systemMediaController.fastForward();
_systemMediaController.rewind();
If you use FCM(silent notification
) with another Platforms(like Flutter Web
), you can control the media being played on mobile from the another platforms.
// example fcm
Map silentNotification = {
'message': {
'data': {
'action': 'play'
}
}
}
FirebaseMessaging.onBackgroundMessage((message){
/// ...another code
final String? action = message.data['action'];
if(action == 'play'){
_systemMediaController.play();
}
});