google / google/ExoPlayer

Use position predicate for PlayerMessage

Open
#10,763 1 comment 0 reactions 1 assignee Claimed by @tonihei View on GitHub
enhancement low priority
Dominant language
Java
Stars
21.9k
Forks
6k
PR merge metrics
No merged PRs in 30d

Description

When using Message object in order to deliver a message in a particular position we usually have to do the next

```
createMessage(target)
?.setLooper(Looper.getMainLooper())
?.setPosition( /* mediaItemIndex= */mediaItemIndex, /* positionMs= */positionInMs)
?.setPayload(playbackMessage)
?.setDeleteAfterDelivery(false)
?.send()
```

Problem is that in some cases we want to deliver the message given a condition for example.

When mPlayer.currentPosition >= positionInMs , so if the user is seeking beyond this positionInMs, the message should be delivered.

Actually we can not set a predicate that meet a particular condition when delivering a message forcing us to add extra code to cover other conditions.

### Propose
Allow to add a predicate when creating the message: predicate: (T) -> Boolean, so the message should be delivered when the predicate is true.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.