Skip to content
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

Add player item monitor for when an item reaches the end when action at end is none #133

Merged
merged 3 commits into from
Oct 28, 2024

Conversation

ceciliasaraiva
Copy link
Contributor

Continuation of logic for when the item reaches the end.
First part here: #110

Here, I've added a monitor for when the player item reached the end. At that moment, since we don't automatically perform any action automatically, I remove it from the player when the FF is enabled.

I continue testing to see if there's any scenario which I might have missed.


This pull request introduces a new feature to handle the event when an AVPlayerItem finishes playing. It adds a new monitor class and integrates it into the existing player wrapper classes.

New Feature: Item Played to End Monitoring

Updates to Player Wrappers

@ceciliasaraiva ceciliasaraiva added the Player PRs related to the Player label Oct 27, 2024
@ceciliasaraiva ceciliasaraiva self-assigned this Oct 27, 2024
@ceciliasaraiva ceciliasaraiva marked this pull request as ready for review October 28, 2024 09:12
@ceciliasaraiva ceciliasaraiva requested a review from a team as a code owner October 28, 2024 09:12
Copy link
Collaborator

@asendra asendra left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With this new event and flag, does playerItemChanged(oldPlayerItem: AVPlayerItem) get called?

The way I understand this works is that the current item ends, it is removed and we call completed() to the delegates, which ends up in PlayerEngine.completed() calling play in the next(new current) item.
Is that correct?

@objc
private func playerItemDidPlayToEndTime(notification: Notification) {
if let playerItem = notification.object as? AVPlayerItem {
print("--> PlayerItemDidPlayToEndTimeMonitor.playerItemDidPlayToEndTime(notification: \(notification))")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be deleted, or convert into a proper Player Log?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no, deleted, I always add a lot of prints to get the whole flow, will delete it.

@ceciliasaraiva
Copy link
Contributor Author

With this new event and flag, does playerItemChanged(oldPlayerItem: AVPlayerItem) get called?

The way I understand this works is that the current item ends, it is removed and we call completed() to the delegates, which ends up in PlayerEngine.completed() calling play in the next(new current) item. Is that correct?

It's still being called. When we remove the old item from player, it's same as advancing to the next item, my guess is that when we call remove again in the playerItemChanged, if not present, nothing happens and then it proceeds to completed as you described above.

@ceciliasaraiva ceciliasaraiva added this pull request to the merge queue Oct 28, 2024
Merged via the queue into main with commit 2ff7d29 Oct 28, 2024
5 checks passed
@ceciliasaraiva ceciliasaraiva deleted the cecilia/MF-373/fix-action-when-item-reach-end branch October 28, 2024 15:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Player PRs related to the Player
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants