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

pip_flutter 封面
插件详情v0.0.3

pip_flutter

适用于 Android 的全新 Flutter 画中画包。当应用在前台运行时,应用也不会被终止。

近 30 天下载
93
喜欢数
60
Pub 分数
60

安装插件

flutter pub add pip_flutter

插件介绍

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

pip_flutter 是一个 Flutter 包,可在 Android 上启用画中画(PiP)功能,使应用程序在最小化或切换到其他应用时仍能在一个小浮动窗口中继续运行。它确保应用在前台保持活跃状态,不会被终止,从而提升媒体播放或持续任务的用户体验。该包与 Android 的 PiP 模式无缝集成,非常适合视频播放器、直播流或任何需要持续后台运行的应用。它支持通过简单的设置步骤进行基本配置。

适合场景

  • 后台视频播放
  • 直播流应用程序
  • 正在进行的任务监控
  • 多任务用户工作流程
  • 背景音频与视觉反馈

主要特点

  • 仅限 Android 的画中画支持
  • 应用在后台保持活跃
  • 所需设置最少
  • 浮在其他应用之上
  • 应用最小化时仍可工作

适合对象

  • 媒体应用
  • 教育工具
  • 远程监控应用
  • 生产力应用
  • 需要持久化 UI 的应用

使用建议

  • 仅限Android平台
  • 需要 Android 8.0 或更高版本
  • 无 iOS 支持
  • 需要正确的清单配置
  • 可能需要额外权限

原始 README

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

pip_flutter

A Flutter plugin for Android and ios for make video in picture in picture mode.


Picture in Picture Mode Flutter



Picture in Picture Mode Disable Picture in Picture Mode

A flutter package pip flutter which will help to put your video in pip mode.

Features 💚

  • Put your video in Picture in Picture mode.
  • Also mute sound and play and pause the video.
  • Make video in full screen mode,set play back speed of video

Installation

First, add pip_flutter as a dependency in your pubspec.yaml file.

Android

Add below permission in your AndroidManifest.xml file ,also specified picture in picture mode in your activity tag and add foreground service for when app is not in background that time app not kill and running in foregorund and also add update code of MainActivity.kt and add PipFlutterPlayerService.

    <uses-permission android:name="android.permission.INTERNET"/>
    <uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
    
    <activity
            android:name=".MainActivity"
            android:supportsPictureInPicture="true"
            android:launchMode="singleTop"
            android:theme="@style/LaunchTheme"
            android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
            android:hardwareAccelerated="true"
            android:windowSoftInputMode="adjustResize"
            android:exported="true"/>
            
    <service
           android:name=".PipFlutterPlayerService"
           android:stopWithTask="false" />

IOS

In Xcode of your project set ios deployment info 11.0 and set in below code in your Info.plist file.

<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
<key>NSBonjourServices</key>
<array>
<string>_dartobservatory._tcp</string>
</array>
<key>UIBackgroundModes</key>
<array>
<string>audio</string>
<string>processing</string>
<string>remote-notification</string>
</array>

How to use

  • PipFlutterPlayerConfiguration : Put this class for your video configuration.
PipFlutterPlayerConfiguration pipFlutterPlayerConfiguration =
const PipFlutterPlayerConfiguration(
  aspectRatio: 16 / 9,
  fit: BoxFit.contain,
);
  • PipFlutterPlayerDataSource : Put this class for declare your video type url and url.
PipFlutterPlayerDataSource dataSource = PipFlutterPlayerDataSource(
  PipFlutterPlayerDataSourceType.network,
  'http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4',
);
  • PipFlutterPlayer :
PipFlutterPlayer(
controller: pipFlutterPlayerController,
key: pipFlutterPlayerKey,
),
  • Make your video in Pip mode put this code on your onTap.
pipFlutterPlayerController.enablePictureInPicture(pipFlutterPlayerKey);
  • And make your video in disable mode put this code on your onTap.
pipFlutterPlayerController.disablePictureInPicture();

Run the example app in the exmaple folder to find out more about how to use it.

所属分类

依赖

依赖清单 7 项

源码仓库

使用此插件的项目

暂无相关数据。