Migrating to react-native-theoplayer
v2.x
The v2 release of react-native-theoplayer
comes with a number of breaking API changes.
The THEOplayerView
component is now split into two separate objects,
THEOplayerView
and THEOplayer
.
In addition, events are being dispatched to subscribed listeners instead of through callback properties.
In this section we will highlight the differences between the old and new approach in order to allow a smooth transition.
Player Creation
The THEOplayerView
component is created and mounted as before.
Instead of passing all player properties, such as paused
, muted
and volume
,
as properties to the THEOplayerView
component, we now pass a onPlayerReady
callback that gives a THEOplayer
object once it is created and ready. This interface
allows directly setting properties or executing methods
such as player.autoplay = true
and player.pause()
.
v1.x | >= v2.x |
---|---|
|
|
Listening to Player Events
As of v2.x, the event callbacks have been removed from THEOplayerView
and replaced
by a subscription approach.
v1.x | >= v2.x |
---|---|
|
|
AdsAPI and CastAPI
The existing ads and casting API's work the same as before. Instead of requesting an API from the view's reference, it can now be requested directly from the player instance.
v1.x | >= v2.x |
---|---|
|
|