-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support standard actions at item playback end #745
Comments
Here is an approach on how we can proceed in a playlist to move from an item to another, and pausing the last item to keep the last frame: struct PlayerView: View {
@StateObject private var player = Player(items: [
.simple(url: URL(string: "https://rts-vod-amd.akamaized.net/ww/13444390/f1b478f7-2ae9-3166-94b9-c5d5fe9610df/master.m3u8")!),
.simple(url: URL(string: "https://rts-vod-amd.akamaized.net/ww/13444333/feb1d08d-e62c-31ff-bac9-64c0a7081612/master.m3u8")!)
])
var body: some View {
SystemVideoView(player: player)
.ignoresSafeArea()
.onAppear(perform: player.play)
.onReceive(player.$currentIndex) { newValue in
if newValue == player.items.count - 1 {
player.actionAtItemEnd = .pause
}
else {
player.actionAtItemEnd = .advance
}
}
}
} |
The approach of changing the The alternative naive approach described in another issue comment, something like: .onReceive(player.propertiesPublisher.slice(at: \.playbackState).receiveOnMainThread()) { state in
guard state == .ended else { return }
player.advanceToNextItem()
} for With the above naive implementation, at item transitions, there is a body refresh (due to the published A more correct way of implementing the above would therefore be: .onReceive(player: model.player, assign: \.playbackState, to: $playbackState)
.onChange(of: playbackState) { state in
guard state == .ended else { return }
model.player.advanceToNextItem()
} with a local This improved implementation is not optimal, though, as it does not provide for gapless transitions between items, unlike the implementation described in the previous comment. Note The implementation in the previous comment has only a view. If it had an underlying view model the corresponding code would probably be better there. |
We had to update item status management to make it possible to handle new possible scenarios after item playback ends. If To handle this new use case:
|
As a developer integrating Pillarbox I might want to have playback pause when playback of an item ends, so that the user can seek back into the content rather than restart playback at its beginning.
For more information see the following comment.
Acceptance criteria
Tasks
actionAtItemEnd
as mutablePlayer
property..ended
state with rate 0, seeking elsewhere must reset the state to.paused
..pause
behavior. Aneof
(resp.stop
) should be received since the content was played entirely.play
should be received for a new playback session (new comScore identifier).Fix behavior so that it is possible to implement automatic transitions in playlists when the behavior is.pause
, see this comment.The text was updated successfully, but these errors were encountered: