Skip to content

Commit 65d4e10

Browse files
committed
Update README.md
1 parent 25e1f3d commit 65d4e10

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

README.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ Please note that using videos from URLs requires ensuring that you have the righ
1313
## [SwiftUI video player example](https://github.com/The-Igor/swiftui-loop-videoplayer-example)
1414

1515
![The concept](https://github.com/The-Igor/swiftui-loop-videoplayer-example/blob/main/swiftui-loop-videoplayer-example/img/video_filters.gif)
16+
![The concept](https://github.com/The-Igor/swiftui-loop-videoplayer-example/blob/main/swiftui-loop-videoplayer-example/img/vector.gif)
1617

1718
## API Specifications
1819

@@ -45,8 +46,42 @@ Please note that using videos from URLs requires ensuring that you have the righ
4546
| `filter(CIFilter, clear: Bool)` | Applies a specific Core Image filter to the video. If `clear` is true, any existing filters on the stack are removed before applying the new filter; otherwise, the new filter is added to the existing stack. |
4647
| `removeAllFilters` | Command to remove all applied filters from the video playback. |
4748
| `audioTrack(String)` | Command to select a specific audio track based on language code. The `languageCode` parameter specifies the desired audio track's language (e.g., "en" for English). |
49+
| `addVector(ShapeLayerBuilderProtocol, clear: Bool)` | Command to add a vector graphic layer over the video stream. The `builder` parameter is an instance conforming to `ShapeLayerBuilderProtocol`. The `clear` parameter specifies whether to clear existing vector layers before adding the new one. |
50+
| `removeAllVectors` | Command to remove all vector graphic layers from the video stream. |
4851

4952

53+
### Additional Notes on Adding and Removing Vector Graphics
54+
55+
When you use the `addVector` command, you can dynamically add a new vector graphic layer (such as a logo or animated vector) over the video stream. This is particularly useful for enhancing the user experience with overlays, such as branding elements, animated graphics.
56+
57+
**Adding a Vector Layer**:
58+
- The `addVector` command takes a `ShapeLayerBuilderProtocol` instance. This protocol defines the necessary method to build a `CAShapeLayer` based on the given geometry (frame, bounds).
59+
- The `clear` parameter determines whether existing vector layers should be removed before adding the new one. If set to `true`, all existing vector layers are cleared, and only the new layer will be displayed.
60+
- The vector layer will be laid out directly over the video stream, allowing it to appear as part of the video playback experience.
61+
62+
These commands allow developers to seamlessly manage vector elements over a video, providing flexible options for adding and removing visual enhancements during playback. By leveraging the `ShapeLayerBuilderProtocol`, developers can create custom vector graphics that integrate smoothly into the video content.
63+
64+
### ShapeLayerBuilderProtocol
65+
66+
```swift
67+
/// A protocol defining a builder for creating shape layers with a unique identifier.
68+
///
69+
/// Conforming types will be able to construct a CAShapeLayer based on provided frame, bounds, and center.
70+
@available(iOS 14, macOS 11, tvOS 14, *)
71+
public protocol ShapeLayerBuilderProtocol: Identifiable {
72+
73+
var id : UUID { get }
74+
75+
/// Builds a CAShapeLayer using specified geometry.
76+
///
77+
/// - Parameters:
78+
/// - geometry: A tuple containing frame, bounds, and center as `CGRect` and `CGPoint`.
79+
/// - Returns: A configured `CAShapeLayer`.
80+
@MainActor
81+
func build(with geometry: (frame: CGRect, bounds: CGRect)) -> CAShapeLayer
82+
83+
}
84+
5085
### Additional Notes on Brightness and Contrast
5186

5287
- **Brightness and Contrast**: These settings function also filters but are managed separately from the filter stack. Adjustments to brightness and contrast are applied additionally and independently of the image filters.

0 commit comments

Comments
 (0)