Skip to content

Commit f6e09ff

Browse files
committed
readme
1 parent c736f8c commit f6e09ff

File tree

3 files changed

+8
-12
lines changed

3 files changed

+8
-12
lines changed

README.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ The player's functionality is designed around a dual interaction model:
2020

2121
- **Commands and Settings**: Through these, you instruct the player on what to do and how to do it. Settings define the environment and initial state, while commands offer real-time control.
2222

23-
- **Event Feedback**: Through event handling, the player communicates back to the application, informing it of internal changes that may need attention.
23+
- **Event Feedback**: Through event handling, the player communicates back to the application, informing it of internal changes that may need attention. Due to the nature of media players, especially in environments with dynamic content or user interactions, the flow of events can become flooded. To manage this effectively and prevent the application from being overwhelmed by the volume of incoming events, the system collects these events every second and returns them as a batch.
2424

2525
## API Specifications
2626

@@ -98,12 +98,13 @@ The player's functionality is designed around a dual interaction model:
9898

9999
| Event | Description |
100100
|------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------|
101-
| `idle` | Represents a state where the player is idle, meaning it is not currently performing any action. |
102101
| `seek(Bool, currentTime: Double)` | Represents an end seek action within the player. The first parameter (`Bool`) indicates whether the seek was successful, and the second parameter (`currentTime`) provides the time (in seconds) to which the player is seeking. |
103102
| `paused` | Indicates that the player's playback is currently paused. This state occurs when the player has been manually paused by the user or programmatically through a method like `pause()`. The player is not playing any content while in this state. |
104103
| `waitingToPlayAtSpecifiedRate` | Indicates that the player is currently waiting to play at the specified rate. This state generally occurs when the player is buffering or waiting for sufficient data to continue playback. It can also occur if the playback rate is temporarily reduced to zero due to external factors, such as network conditions or system resource limitations. |
105104
| `playing` | Indicates that the player is actively playing content. This state occurs when the player is currently playing video or audio content at the specified playback rate. This is the active state where media is being rendered to the user. |
106-
105+
| `currentItemChanged` | Triggered when the player's `currentItem` is updated to a new `AVPlayerItem`. This event indicates a change in the media item currently being played. |
106+
| `currentItemRemoved` | Occurs when the player's `currentItem` is set to `nil`, indicating that the current media item has been removed from the player. |
107+
| `volumeChanged` | Happens when the player's volume level is adjusted. This event provides the new volume level, which ranges from 0.0 (muted) to 1.0 (maximum volume). |
107108

108109
### Additional Notes on Adding and Removing Vector Graphics
109110

@@ -163,8 +164,8 @@ or in a declarative way
163164
.onPlayerTimeChange { newTime in
164165
// Current video playback time
165166
}
166-
.onPlayerEventChange { event in
167-
// Player event
167+
.onPlayerEventChange { events in
168+
// Player events
168169
}
169170
```
170171

Sources/swiftui-loop-videoplayer/ExtVideoPlayer.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public struct ExtVideoPlayer: View{
2525
@State private var currentTime: Double = 0.0
2626

2727
/// The current state of the player event,
28-
@State private var playerEvent: [PlayerEvent] = [.idle]
28+
@State private var playerEvent: [PlayerEvent] = []
2929

3030
/// A publisher that emits the current playback time as a `Double`. It is initialized privately within the view.
3131
@State private var timePublisher = PassthroughSubject<Double, Never>()
@@ -114,7 +114,7 @@ public struct ExtVideoPlayer: View{
114114
.onReceive(timePublisher, perform: { time in
115115
currentTime = time
116116
})
117-
.onReceive(eventPublisher.collect(.byTime(DispatchQueue.main, .seconds(2))), perform: { event in
117+
.onReceive(eventPublisher.collect(.byTime(DispatchQueue.main, .seconds(1))), perform: { event in
118118
playerEvent = event
119119
})
120120
.preference(key: CurrentTimePreferenceKey.self, value: currentTime)

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

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,6 @@ import AVFoundation
1212
@available(iOS 14.0, macOS 11.0, tvOS 14.0, *)
1313
public enum PlayerEvent: Equatable {
1414

15-
/// Represents a state where the player is idle.
16-
case idle
17-
1815
/// Represents an end seek action within the player.
1916
/// - Parameters:
2017
/// - Bool: Indicates whether the seek was successful.
@@ -63,8 +60,6 @@ public enum PlayerEvent: Equatable {
6360
extension PlayerEvent: CustomStringConvertible {
6461
public var description: String {
6562
switch self {
66-
case .idle:
67-
return "Idle"
6863
case .seek(let success, _):
6964
return success ? "SeekSuccess" : "SeekFail"
7065
case .paused:

0 commit comments

Comments
 (0)