A Flutter plugin to handle iOS Playing Info Center events such as play, pause, title, etc.
flappy_infocenter: 1.0.1
The plugin allows to display easily the playing info center on iOS. This is the built-in notification used to display audio or video information in the notification center.
It will work if and only if a player is currently launched. The tests have been made using the
audioplayers
plugin.
First, import the package in your code
import 'package:flappy_infocenter/flappy_infocenter.dart';
You can then access the FlappyInfoCenter singleton freely in your code.
All the methods will overwrite what is currently displayed in the info center.
static setInfo(String author, String title) async
Displays in the info center an author and a title for the given audio or video played.
static setProgress(int progress) async
Displays in the info center the progress in seconds for the given audio or video played. Will work if and only if a total duration has been set.
static setDuration(int duration) async
Displays in the info center the total duration in seconds of the given audio or video played.
static setImage(String url) async
Displays in the info center an image for the given audio or video played. The image must be a valid URL.
static setPlayerListener(PlayerListener listener)
Allows to get info center control events. Currently, only PLAY and PAUSE works.
Example :
FlappyInfoCenter.setPlayerListener((PlayerState state) {
switch (state) {
case PlayerState.PLAY:
play();
break;
case PlayerState.PAUSE:
pause();
break;
case PlayerState.NEXT:
break;
case PlayerState.PREVIOUS:
break;
}
});