Wayaer/fl_pip

How to enable the PiP mode if home button get clicked?

Closed this issue · 2 comments

Hi, thanks for the awesome library. I have a question:
How to enable the PiP mode if the home button gets clicked?

Wayaer commented

Call FlPiP().enable() to enable PiP,

class _State extends State<T> with WidgetsBindingObserver{

  @override
  void initState() {
    super.initState();
    WidgetsBinding.instance.addObserver(this);
  }

  @override
  void didChangeAppLifecycleState(AppLifecycleState state) {
    super.didChangeAppLifecycleState(state);
    switch (state) {
      case AppLifecycleState.inactive:
        break;
      case AppLifecycleState.paused: 
     /// app enters background
       FlPiP().enable()
        break;
      case AppLifecycleState.resumed: 
        break;
      case AppLifecycleState.detached:
        break;
    }
  }
  @override
  void dispose() {
    super.dispose();
    WidgetsBinding.instance.removeObserver(this);
  }
}

Thanks <3