Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
075e3ac
[UPDATE] - add parameter auto enter to setAutoPipMode
Jan 20, 2023
020fa5d
feat: Android 14 Supported
engine-ydsong-uxplus Jan 9, 2024
5e589ed
Setup fvm and updated projects to compile with flutter 3.24
PuntitOwO Sep 30, 2024
fbba9f1
Merge branch 'main' of song011794/simple_pip_mode_flutter into song01…
PuntitOwO Sep 30, 2024
6e6e53c
refactor: pass flutter analyze without issues found
PuntitOwO Sep 30, 2024
9987c5c
Merge branch 'song011794-main'
PuntitOwO Sep 30, 2024
9f40c8d
chore: update pubspec, readme and changelog
PuntitOwO Sep 30, 2024
c410462
Merge branch 'feature/auto-enter-param' of git:af-ffr/simple_pip_mode…
PuntitOwO Sep 30, 2024
f8c1356
fix: wrong autoEnter type inference
PuntitOwO Oct 1, 2024
f4f19b7
chore: merge 'af-ffr-feature/auto-enter-param'
PuntitOwO Oct 1, 2024
0f1490f
chore: update readme and changelog
PuntitOwO Oct 1, 2024
3c9d5b3
chore: update dependencies and clean up code
PuntitOwO Oct 1, 2024
f2a23cf
feat: add AspectRatio and usage
PuntitOwO Oct 1, 2024
43754fa
refactor: refactor example code
PuntitOwO Oct 1, 2024
ac2108f
refactor: PipActionEnum
PuntitOwO Oct 1, 2024
027ac9f
fix: fix documentation
PuntitOwO Oct 1, 2024
6f23fc1
chore: update changelog
PuntitOwO Oct 1, 2024
ab156af
chore: update README.md to include videos
PuntitOwO Oct 1, 2024
ded6cb4
chore: update changelog
PuntitOwO Oct 1, 2024
711635a
chore: update README.md to include videos
PuntitOwO Oct 1, 2024
5d3debc
fix: downgrade flutter_lints
PuntitOwO Oct 1, 2024
044be85
fix: remove flutter upper bound
PuntitOwO Oct 1, 2024
39ad08d
fix: flutter analysis issues
PuntitOwO Oct 1, 2024
cf25937
feat: add media with seek action and fix actions name
kmartins Dec 28, 2024
726c9da
feat: add media with seek action and fix actions name (#21)
PuntitOwO Jan 23, 2025
66255b2
chore: run dart format
PuntitOwO Jan 23, 2025
f48f5a2
chore: change example app gradle plugin apply method
PuntitOwO Jan 23, 2025
b367c24
refactor: change indentation to 4 spaces
PuntitOwO Jan 23, 2025
4c2c258
refactor: separated each method implementation of onMethodCall
PuntitOwO Jan 23, 2025
e66c403
refactor: add space after comma
PuntitOwO Jan 23, 2025
c69a8df
refactor: clean code in SimplePip
PuntitOwO Jan 23, 2025
8631b0e
docs: add documentation to AspectRatio
PuntitOwO Jan 23, 2025
8cf8db4
feat: add deprecation notice
PuntitOwO Jan 23, 2025
64073e1
chore: update README and CHANGELOG
PuntitOwO Jan 23, 2025
1d17d0e
Merge branch 'main' into sync
sargisshahinyan Apr 10, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .fvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"flutter": "3.24.3"
}
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
# The .vscode folder contains launch configuration and tasks you configure in
# VS Code which you may wish to be included in version control, so this line
# is commented out by default.
#.vscode/
.vscode/

# Flutter/Dart/Pub related
# Libraries should not include pubspec.lock, per https://dart.dev/guides/libraries/private-files#pubspeclock.
Expand All @@ -27,3 +27,6 @@
.dart_tool/
.packages
build/

# FVM Version Cache
.fvm/
19 changes: 18 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,23 @@
## 1.1.0

* Fix namespace issue and add a new media action preset by [kmartins](https://github.com/kmartins): [PR #21](https://github.com/PuntitOwO/simple_pip_mode_flutter/pull/21)
* Add deprecation warning to `PipWidget.builder` and `PipWidget.pipBuilder` parameters. They will be removed in v2.0.0.
* Refactor native code method dispatcher to separate methods for each method call.
* Update README.md to include new features and deprecation warning.

## 1.0.0

* Android 14 support by [song011794](https://github.com/song011794): [PR #12](https://github.com/PuntitOwO/simple_pip_mode_flutter/pull/12)
* Add auto enter parameter to `setAutoPipMode` by [af-ffr](https://github.com/af-ffr): [PR #8](https://github.com/PuntitOwO/simple_pip_mode_flutter/pull/8)
* Add `AspectRatio` record type.
* Update README.md to inlcude updated videos of new features.
* Actions code refactor to pass flutter static analysis.
* Dependencies updated.
* Refactor example app.

## 0.8.0

* Pip Actions implemented by [Erick Daros](https://github.com/erickdaros): [Issue #5](https://github.com/PuntitOwO/simple_pip_mode_flutter/issues/5).
* Pip Actions implemented by [Erick Daros](https://github.com/erickdaros): [PR #6](https://github.com/PuntitOwO/simple_pip_mode_flutter/pull/6).

## 0.7.1

Expand Down
69 changes: 48 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@ Big shout out to the original author of this library [@puntitOwO](https://www.gi

Provides methods to check feature availability, enter PIP mode, callbacks for mode change and PIP Actions support.

![pip_example](https://user-images.githubusercontent.com/69210614/154329387-bd90ce0b-d563-4173-b2d0-2cbcc62b670c.gif)
[main.webm](https://github.com/user-attachments/assets/8d9dd33d-a008-41af-a663-579c3a9cae7d)

[auto_enter.webm](https://github.com/user-attachments/assets/9704e36b-351d-440e-b66b-cf6ad1523d92)

[actions.webm](https://github.com/user-attachments/assets/d171aaf5-2b21-4c49-9269-bd58cb3858b7)

# Reasoning behind forking this library

Expand All @@ -30,16 +34,31 @@ In the `dependencies:` section of your `pubspec.yaml`, add the following line:
simple_pip_mode: <latest_version>
```

# Usage
# Table of contents

- [Features](#features)
- [Installation](#installation)
- [Table of contents](#table-of-contents)
- [Usage](#usage)
- [Update manifest](#update-manifest)
- [Verify pip support](#verify-pip-support)
- [Entering pip mode](#entering-pip-mode)
- [Setting automatic pip mode](#setting-automatic-pip-mode)
- [Enabling callbacks](#enabling-callbacks)
- [Activity wrapper](#activity-wrapper)
- [Kotlin](#kotlin)
- [Java](#java)
- [Callback helper](#callback-helper)
- [Kotlin](#kotlin-1)
- [Java](#java-1)
- [Using callbacks](#using-callbacks)
- [Using the PIP widget](#using-the-pip-widget)
- [Using PIP Actions](#using-pip-actions)
- [Notes](#notes)
- [Multi-platform apps](#multi-platform-apps)
- [Contribute](#contribute)

This section has example code for the following tasks:
* [Update manifest](#update-manifest)
* [Verify PIP support](#verify-pip-support)
* [Entering PIP mode](#entering-pip-mode)
* [Enabling callbacks](#enabling-callbacks)
* [Using callbacks](#using-callbacks)
* [Using the PIP Widget](#using-the-pip-widget)
* [Using PIP Actions](#using-pip-actions)
# Usage

## Update manifest

Expand Down Expand Up @@ -90,7 +109,7 @@ This way, when user presses home (or uses home gesture), the app enters PIP mode

There's two ways of enabling callbacks:
* [Activity wrapper](#activity-wrapper) (Recommended!)
* [Callback helper](#callback-helper)
* [Callback helper](#callback-helper) (The old, manual way)

### Activity wrapper

Expand Down Expand Up @@ -178,16 +197,18 @@ SimplePip _pip = SimplePip(
To use the widget, you need to [enable callbacks](#enabling-callbacks) first.
Import `pip_widget.dart` file.

Add a `PipWidget` widget to your tree and give it a `builder` or a `child`, and a `pipBuilder` or a `pipChild`.
Add a `PipWidget` widget to your tree and give it a `child` and a `pipChild`.

> [!Note]
> `builder` and `pipBuilder` are deprecated. Use a `Builder` as the `child` or `pipChild` instead.

```dart
import 'package:simple_pip_mode/pip_widget.dart';
class MyWidget extends StatelessWidget {
Widget build(BuildContext context) {
return PipWidget(
builder: (context) => Text('This is built when PIP mode is not active'),
child: Text('This widget is not used because builder is not null'),
//pipBuilder: (context) => Text('This is built when PIP mode is active'),
pipChild: Text('This widget is used because pipBuilder is null'),
child: Text('This is built when PIP mode is not active'),
pipChild: Text('This is built when PIP mode is active'),
);
}
}
Expand All @@ -197,7 +218,7 @@ You can also pass callbacks directly to `PipWidget`.
## Using PIP Actions

To use PIP actions, you need to specify a `pipLayout` preset on your `PipWidget`.
The current available action layout presets are focused on giving support to media reproduction controls. They are `media`, `media_only_pause` and `media_live`. Those are defined on the `[PipActionsLayout]` enum.
The current available action layout presets are focused on giving support to media reproduction controls. They are `media`, `media_only_pause`, `media_live` and `mediaWithSeek10`. Those are defined on the `[PipActionsLayout]` enum.

You can also add a `onPipAction` listener to handle actions callbacks from `PipWidget`. This can be defined on `SimplePip(onPipAction: ...)` too.
```dart
Expand All @@ -213,14 +234,16 @@ class MyWidget extends StatelessWidget {
switch (action) {
case PipAction.play:
// example: videoPlayerController.play();
break;
case PipAction.pause:
// example: videoPlayerController.pause();
break;
case PipAction.next:
// example: videoPlayerController.next();
case PipAction.previous:
// example: videoPlayerController.previous();
case PipAction.rewind:
// example: videoPlayerController.seek(-10);
case PipAction.forward:
// example: videoPlayerController.seek(10);
default:
break;
}
Expand Down Expand Up @@ -248,6 +271,10 @@ Calling `SimplePip` methods on a non-Android device will raise a `MissingPluginE

# Contribute

Huge thanks to [Erick Daros](https://github.com/erickdaros) for PIP Actions feature.
Huge thanks to:
* [Erick Daros](https://github.com/erickdaros) for PIP Actions feature.
* [song011794](https://github.com/song011794) for updating the plugin to Android 14.
* [af-ffr](https://github.com/af-ffr) for updating the plugin to add auto enter parameter.
* [kmartins](https://github.com/kmartins) for updating the plugin to add more actions.

I'm currently working on more features, so issues and pull requests are appreciated!
Issues and pull requests are appreciated!
17 changes: 10 additions & 7 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ group 'cl.puntito.simple_pip_mode'
version '1.0-SNAPSHOT'

buildscript {
ext.kotlin_version = '1.6.10'
ext.kotlin_version = '1.8.0'
repositories {
google()
mavenCentral()
}

dependencies {
classpath 'com.android.tools.build:gradle:4.1.0'
classpath 'com.android.tools.build:gradle:8.0.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
Expand All @@ -25,26 +25,29 @@ apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'

android {
compileSdkVersion 31
compileSdk 34
namespace = "cl.puntito.simple_pip_mode"

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
sourceCompatibility JavaVersion.VERSION_17
targetCompatibility JavaVersion.VERSION_17
}

kotlinOptions {
jvmTarget = '1.8'
jvmTarget = JavaVersion.VERSION_17
}

sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}

defaultConfig {
minSdkVersion 16
minSdkVersion 21
}
}

dependencies {
implementation "androidx.core:core:1.10.1"
implementation 'androidx.annotation:annotation:1.7.0'
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
}
3 changes: 1 addition & 2 deletions android/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="cl.puntito.simple_pip_mode">
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
</manifest>
Original file line number Diff line number Diff line change
Expand Up @@ -7,26 +7,26 @@ import io.flutter.embedding.engine.FlutterEngine


open class PipCallbackHelper {
private val CHANNEL = "puntito.simple_pip_mode"
private lateinit var channel: MethodChannel
private val CHANNEL = "puntito.simple_pip_mode"
private lateinit var channel: MethodChannel

fun configureFlutterEngine(@NonNull flutterEngine: FlutterEngine) {
channel = MethodChannel(flutterEngine.dartExecutor.binaryMessenger, CHANNEL)
}
fun configureFlutterEngine(@NonNull flutterEngine: FlutterEngine) {
channel = MethodChannel(flutterEngine.dartExecutor.binaryMessenger, CHANNEL)
}

fun setChannel(channel: MethodChannel) {
this.channel = channel
}
fun setChannel(channel: MethodChannel) {
this.channel = channel
}

fun onPictureInPictureModeChanged(active: Boolean) {
if (active) {
channel.invokeMethod("onPipEntered", null)
} else {
channel.invokeMethod("onPipExited", null)
fun onPictureInPictureModeChanged(active: Boolean) {
if (active) {
channel.invokeMethod("onPipEntered", null)
} else {
channel.invokeMethod("onPipExited", null)
}
}
}

fun onPipAction(action: PipAction) {
channel.invokeMethod("onPipAction", action.name.lowercase())
}
fun onPipAction(action: PipAction) {
channel.invokeMethod("onPipAction", action.name.lowercase())
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,16 @@ import io.flutter.embedding.engine.FlutterEngine
import cl.puntito.simple_pip_mode.PipCallbackHelper


open class PipCallbackHelperActivityWrapper: FlutterActivity() {
private var callbackHelper = PipCallbackHelper()
open class PipCallbackHelperActivityWrapper : FlutterActivity() {
private var callbackHelper = PipCallbackHelper()

override fun configureFlutterEngine(@NonNull flutterEngine: FlutterEngine) {
super.configureFlutterEngine(flutterEngine)
callbackHelper.configureFlutterEngine(flutterEngine)
}
override fun configureFlutterEngine(@NonNull flutterEngine: FlutterEngine) {
super.configureFlutterEngine(flutterEngine)
callbackHelper.configureFlutterEngine(flutterEngine)
}

override fun onPictureInPictureModeChanged(active: Boolean, newConfig: Configuration?) {
super.onPictureInPictureModeChanged(active, newConfig)
callbackHelper.onPictureInPictureModeChanged(active)
}
override fun onPictureInPictureModeChanged(active: Boolean, newConfig: Configuration?) {
super.onPictureInPictureModeChanged(active, newConfig)
callbackHelper.onPictureInPictureModeChanged(active)
}
}
Loading