Skip to content

Commit 9c45466

Browse files
committed
update
1 parent 6d82e97 commit 9c45466

File tree

4 files changed

+16
-6
lines changed

4 files changed

+16
-6
lines changed

README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ The player's functionality is designed around a dual ⇆ interaction model:
4747
| | Error Handling | Customizable error messages and visual displays. |
4848
| | Subtitle Support | Add external `.vtt` files or use embedded subtitle tracks. |
4949
| | Custom Overlays | Add vector graphics and custom overlays over the video. |
50+
| | Picture In Picture (PiP) | Picture-in-Picture (PiP) is supported on iOS and iPadOS |
5051
| **Playback Commands** | Idle Command | Initialize without specific playback actions. |
5152
| | Play/Pause | Control playback state. |
5253
| | Seek Command | Move to specific video timestamps. |
@@ -125,13 +126,14 @@ Please note that using videos from URLs requires ensuring that you have the righ
125126
|---------------|-----------------------------------------------------------------------------------------------------|---------|
126127
| **SourceName** | The URL or local filename of the video. | - |
127128
| **Ext** | File extension for the video, used when loading from local resources. This is optional when a URL is provided and the URL ends with the video file extension. | "mp4" |
128-
| **Subtitles** | The URL or local filename of the WebVTT (.vtt) subtitles file to be merged with the video. With a AVMutableComposition approach that is used currently in the package, you cannot directly change the position or size of subtitles. AVFoundation’s built-in handling of “text” tracks simply renders them in a default style, without allowing additional layout options. Take a look on the implementation in the example app (Video8.swift) | - |
129+
| **Subtitles** | The URL or local filename of the WebVTT (.vtt) subtitles file to be merged with the video. With a AVMutableComposition approach that is used currently in the package, you cannot directly change the position or size of subtitles. AVFoundation’s built-in handling of “text” tracks simply renders them in a default style, without allowing additional layout options. Take a look on the implementation in the example app *Video8.swift* | - |
129130
| **Gravity** | How the video content should be resized to fit the player's bounds. | .resizeAspect |
130131
| **TimePublishing** | Specifies the interval at which the player publishes the current playback time. | - |
131132
| **Loop** | Whether the video should automatically restart when it reaches the end. If not explicitly passed, the video will not loop. | false |
132133
| **Mute** | Indicates if the video should play without sound. | false |
133134
| **NotAutoPlay** | Indicates if the video should not play after initialization. Notice that if you use `command` as a control flow for the player the start command should be `.idle` | false |
134135
| **EnableVector** | Use this struct to activate settings that allow the addition of vector-based overlays via commands. If it is not passed via settings, any commands to `addVector` or `removeAllVectors` will have no effect. | Not Enabled |
136+
|**PictureInPicture()**| Enable Picture-in-Picture (PiP) support. If not passed than any command like `startPiP` or `stopPiP` have no effect. Take a look the example app *Video11.swift* |
135137

136138
### Additional Notes on Settings
137139

@@ -172,6 +174,8 @@ In cases where you need to re-issue a command that might appear redundant but is
172174
| `playbackSpeed(Float)` | Command to adjust the playback speed of the video. The `speed` parameter is a `Float` value representing the playback speed (e.g., 1.0 for normal speed, 0.5 for half speed, 2.0 for double speed). If a negative value is passed, it will be clamped to 0.0. |
173175
| `loop` | Command to enable looping of the video playback. By default, looping is enabled, so this command will have no effect if looping is already active. |
174176
| `unloop` | Command to disable looping of the video playback. This command will only take effect if the video is currently being looped. |
177+
| `startPiP` | Command to initiate **Picture-in-Picture (PiP)** mode for video playback. If the PiP feature is already active, this command will have no additional effect. |
178+
| `stopPiP` | Command to terminate **Picture-in-Picture (PiP)** mode, returning the video playback to its inline view. If PiP is not active, this command will have no effect. |
175179

176180
### Visual Adjustment Commands
177181

Sources/swiftui-loop-videoplayer/enum/PlaybackCommand.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,9 +97,12 @@ public enum PlaybackCommand: Equatable {
9797
case audioTrack(languageCode: String)
9898

9999
#if os(iOS)
100+
/// Command to initiate Picture-in-Picture (PiP) mode for video playback. If the PiP feature is already active, this command will have no additional effect.
100101
case startPiP
101102

103+
/// Command to terminate Picture-in-Picture (PiP) mode, returning the video playback to its inline view. If PiP is not active, this command will have no effect.
102104
case stopPiP
105+
103106
#endif
104107

105108
public static func == (lhs: PlaybackCommand, rhs: PlaybackCommand) -> Bool {

Sources/swiftui-loop-videoplayer/enum/PlayerEvent.swift

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,14 @@ public enum PlayerEvent: Equatable {
6060
/// - Parameter VPErrors: The error from the VPErrors enum associated with this case.
6161
case error(VPErrors)
6262

63-
63+
/// Event triggered when the bounds of the video player change.
64+
/// - Parameter CGRect: The new bounds of the video player.
6465
case boundsChanged(CGRect)
65-
66+
67+
/// Event triggered when Picture-in-Picture (PiP) mode starts.
6668
case startedPiP
67-
69+
70+
/// Event triggered when Picture-in-Picture (PiP) mode stops.
6871
case stoppedPiP
6972
}
7073

Sources/swiftui-loop-videoplayer/settings/PictureInPicture .swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//
2-
// PictureInPicture .swift
2+
// PictureInPicture.swift
33
//
44
//
55
// Created by Igor Shelopaev on 21.01.25.
@@ -8,7 +8,7 @@
88
import Foundation
99

1010

11-
/// Represents a settings structure that enables looping functionality, conforming to `SettingsConvertible`.
11+
/// Represents a PictureInPicture functionality, conforming to `SettingsConvertible`.
1212
@available(iOS 14.0, macOS 11.0, tvOS 14.0, *)
1313
public struct PictureInPicture : SettingsConvertible{
1414

0 commit comments

Comments
 (0)