搜索插件、代码仓与 APP 分类

插件详情v1.7.5

flutter_in_app_pip

一个 Flutter 包,可轻松在 Flutter 应用中实现画中画功能。

AndroidiOSWebmacOSWindowsLinux
近 30 天下载
2560
喜欢数
62
Pub 分数
160

安装插件

flutter pub add flutter_in_app_pip

插件介绍

基于插件公开信息、社区数据与项目使用情况整理的选型参考。

一个 Flutter 包,可简化在 Flutter 应用中实现画中画(PiP)模式。它使用户能够在浏览应用的其他部分或切换到其他应用时,继续在小浮动窗口中观看视频内容。该包支持 Android、iOS、Web、macOS、Windows 和 Linux 多个平台,为不同设备提供一致的 PiP 体验。非常适合媒体密集型应用,如视频播放器、直播或视频会议工具。

适合场景

  • 后台视频播放
  • 画中画直播
  • 视频会议应用
  • 需要多任务处理的媒体应用
  • 带有视频内容的教育类应用程序

主要特点

  • 跨平台画中画支持
  • 简单 API 集成
  • 浮动视频窗口
  • 自动画中画状态管理
  • 支持 Android、iOS、Web、macOS、Windows 和 Linux

适合对象

  • 媒体应用开发者
  • 视频流媒体平台
  • 互动式学习应用
  • 需要后台视频播放的应用
  • 面向多个平台的开发者

使用建议

  • 需要平台特定权限
  • 某些网页浏览器上的画中画功能受限
  • iOS 画中画可能需要额外配置
  • 并非所有设备都支持画中画模式
  • Web PiP 支持因浏览器而异

原始 README

以下为关联源码仓库的 README 原文快照,最新内容请访问源码仓库。

In App PiP for Flutter

A Flutter Package to help easily implement in-app PiP(Picture in Picture) in a flutter application. Written completely in dart.

Features

  • Easily Implement PiP(Picture in Picture) in app.

  • Navigatable PiP Widget which allows navigation inside the PiP Window.

  • Automatically Handle showing different widgets in the original view when in pip and when not in pip.

  • Provides the ability to update the size of the pip widget later after starting pip.

  • Provides the ability to set the borders to which pip can be dragged.

  • Provides the ability to make the window resizable(pinch-in/out).

  • Provides the ability to make the window non-movable.

  • Provides the ability to set the initial corner of the PIP window.

  • Provides the ability to set minimum and maximum size of the PIP window, if resizable.

Getting started

  • Import the package.

  • Replace your MaterialApp with PiPMaterialApp (If using MaterialApp.router, you can replace it with PiPMaterialApp.router).

  • Optionally provide the pip parameters. These correspond to various parameters such as height and width of your pip widget.

Usage

After replacing your MaterialApp with PiPMaterialApp, use

 PictureInPicture.startPiP(pipWidget: MyPiPWidget());

to start PiP view in your app.

When you wish to stop PiP, use

PictureInPicture.stopPiP();

Use PiPWidget for additional functionalities like handling events on close of pip e.g.

PictureInPicture.startPiP(
    pipWidget:PiPWidget(
      child: ChildWidget(),
      onPiPClose: (){
      //Handle closing events e.g. dispose controllers.
      
      },
      elevation: 10,        //Optional
      pipBorderRadius: 10,  //Optional
      )
);

Use NavigatablePiPWidget for Navigation inside the PiP Window e.g.

PictureInPicture.startPiP(
    pipWidget:NavigatablePiPWidget(
      child: ChildWidget(),
      onPiPClose: (){
      //Handle closing events e.g. dispose controllers.
      
      },
      elevation: 10,        //Optional
      pipBorderRadius: 10,  //Optional
      )
);

Additionally, you can also use PiPCapableWidget to handle the view changes in case of PiP start and stop e.g.

PiPCapableWidget(
    whileNotInPip: ChildToShowWhileNotInPiP(),
    whileInPip: ChildToShowWhileInPiP(),      //Optional
);

Update the parameters of the pip view like below:

PictureInPicture.updatePiPParams(
                    pipParams: PiPParams(
                        pipWindowHeight: 144,
                        pipWindowWidth: 256,
                        bottomSpace: 64,
                        leftSpace: 64,
                        rightSpace: 64,
                        topSpace: 64,
                        maxSize: Size(256, 144),
                        minSize: Size(144, 108),
                        movable: true,
                        resizable: false,
                        initialCorner: PIPViewCorner.bottomRight,
                        ),
                  );

Note

That's it. Enjoy! Also, this package is 100% compatible with my other flutter plugin android_pip

所属分类

源码仓库

使用此插件的项目