mirror of
https://github.com/samsonjs/media.git
synced 2026-03-31 10:25:48 +00:00
Add a dev guide section about ForwardingPlayer
Issue: google/ExoPlayer#9897 Issue: google/ExoPlayer#10268 #minor-release PiperOrigin-RevId: 450428520
This commit is contained in:
parent
ffb75d746c
commit
96f35bbc3a
1 changed files with 22 additions and 0 deletions
|
|
@ -212,6 +212,28 @@ If you're instantiating renderers directly, pass a
|
|||
`AsynchronousMediaCodecAdapter.Factory` to the `MediaCodecVideoRenderer` and
|
||||
`MediaCodecAudioRenderer` constructors.
|
||||
|
||||
### Intercepting method calls with `ForwardingPlayer` ###
|
||||
|
||||
You can customize some of the behavior of a `Player` instance by wrapping it in
|
||||
a subclass of `ForwardingPlayer` and overriding methods in order to do any of
|
||||
the following:
|
||||
|
||||
* Access parameters before passing them to the delegate `Player`.
|
||||
* Access the return value from the delegate `Player` before returning it.
|
||||
* Re-implement the method completely.
|
||||
|
||||
When overriding `ForwardingPlayer` methods it's important to ensure the
|
||||
implementation remains self-consistent and compliant with the `Player`
|
||||
interface, especially when dealing with methods that are intended to have
|
||||
identical or related behavior. For example, if you want to override every 'play'
|
||||
operation, you need to override both `ForwardingPlayer.play` and
|
||||
`ForwardingPlayer.setPlayWhenReady`, because a caller will expect the behavior
|
||||
of these methdods to be identical when `playWhenReady = true`. Similarly, if you
|
||||
want to change the seek-forward increment you need to override both
|
||||
`ForwardingPlayer.seekForward` to perform a seek with your customized increment,
|
||||
and `ForwardingPlayer.getSeekForwardIncrement` in order to report the correct
|
||||
customized increment back to the caller.
|
||||
|
||||
## MediaSource customization ##
|
||||
|
||||
The examples above inject customized components for use during playback of all
|
||||
|
|
|
|||
Loading…
Reference in a new issue