Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion android/src/main/java/com/theoplayer/PlayerEventEmitter.kt
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,10 @@ class PlayerEventEmitter internal constructor(

fun preparePlayer(player: Player) {
attachListeners(player)

emitPlayerReady(player)
}

fun emitPlayerReady(player: Player) {
val payload = Arguments.createMap()
payload.putMap(
EVENT_PROP_STATE,
Expand Down
4 changes: 2 additions & 2 deletions android/src/main/java/com/theoplayer/ReactTHEOplayerView.kt
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ private const val TAG = "ReactTHEOplayerView"
class ReactTHEOplayerView(private val reactContext: ThemedReactContext) :
FrameLayout(reactContext), LifecycleEventListener {

private val eventEmitter: PlayerEventEmitter =
val eventEmitter: PlayerEventEmitter =
PlayerEventEmitter(reactContext.reactApplicationContext, this)
val broadcast = EventBroadcastAdapter(this)
var presentationManager: PresentationManager? = null
var playerContext: ReactTHEOplayerContext? = null
private var isInitialized: Boolean = false
var isInitialized: Boolean = false
private var config: PlayerConfigAdapter? = null

val adsApi: AdsApiWrapper
Expand Down
2 changes: 1 addition & 1 deletion ios/THEOplayerRCTView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ public class THEOplayerRCTView: UIView {
}
}

private func notifyNativePlayerReady() {
public func notifyNativePlayerReady() {
DispatchQueue.main.async {
let versionString = THEOplayer.version
if let forwardedNativeReady = self.onNativePlayerReady {
Expand Down
5 changes: 5 additions & 0 deletions src/api/THEOplayerView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ export interface THEOplayerViewProps {
*/
config?: PlayerConfiguration;

/**
* Render something instead of the player view.
*/
customPlayerRender?: (playerProps: any) => React.JSX.Element;

/**
* The style applied to the player view.
*/
Expand Down
76 changes: 39 additions & 37 deletions src/internal/THEOplayerView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -406,47 +406,49 @@ export class THEOplayerView extends PureComponent<React.PropsWithChildren<THEOpl
}

public render(): React.JSX.Element {
const { config, style, posterStyle, children } = this.props;
const { config, customPlayerRender, style, posterStyle, children } = this.props;
const { posterActive, poster } = this.state;

const playerProps = {
ref: this._root,
style: StyleSheet.absoluteFill,
config: config || {},
onNativePlayerReady: this._onNativePlayerReady,
onNativeSourceChange: this._onSourceChange,
onNativeLoadStart: this._onLoadStart,
onNativeLoadedData: this._onLoadedData,
onNativeLoadedMetadata: this._onLoadedMetadata,
onNativeVolumeChange: this._onVolumeChange,
onNativeError: this._onError,
onNativeProgress: this._onProgress,
onNativeCanPlay: this._onCanPlay,
onNativePlay: this._onPlay,
onNativePlaying: this._onPlaying,
onNativePause: this._onPause,
onNativeSeeking: this._onSeeking,
onNativeSeeked: this._onSeeked,
onNativeWaiting: this._onWaiting,
onNativeEnded: this._onEnded,
onNativeReadyStateChange: this._onReadStateChange,
onNativeTimeUpdate: this._onTimeUpdate,
onNativeDurationChange: this._onDurationChange,
onNativeRateChange: this._onRateChange,
onNativeSegmentNotFound: this._onSegmentNotFound,
onNativeTextTrackListEvent: this._onTextTrackListEvent,
onNativeTextTrackEvent: this._onTextTrackEvent,
onNativeMediaTrackListEvent: this._onMediaTrackListEvent,
onNativeMediaTrackEvent: this._onMediaTrackEvent,
onNativeAdEvent: this._onAdEvent,
onNativeTHEOliveEvent: this._onTHEOliveEvent,
onNativeCastEvent: this._onCastEvent,
onNativePresentationModeChange: this._onPresentationModeChange,
onNativeDeviceOrientationChanged: this._onDeviceOrientationChanged,
onNativeResize: this._onResize,
} as THEOplayerRCTViewProps;

return (
<View style={[styles.base, style, this.styleOverride()]}>
<THEOplayerRCTView
ref={this._root}
style={StyleSheet.absoluteFill}
config={config || {}}
onNativePlayerReady={this._onNativePlayerReady}
onNativeSourceChange={this._onSourceChange}
onNativeLoadStart={this._onLoadStart}
onNativeLoadedData={this._onLoadedData}
onNativeLoadedMetadata={this._onLoadedMetadata}
onNativeVolumeChange={this._onVolumeChange}
onNativeError={this._onError}
onNativeProgress={this._onProgress}
onNativeCanPlay={this._onCanPlay}
onNativePlay={this._onPlay}
onNativePlaying={this._onPlaying}
onNativePause={this._onPause}
onNativeSeeking={this._onSeeking}
onNativeSeeked={this._onSeeked}
onNativeWaiting={this._onWaiting}
onNativeEnded={this._onEnded}
onNativeReadyStateChange={this._onReadStateChange}
onNativeTimeUpdate={this._onTimeUpdate}
onNativeDurationChange={this._onDurationChange}
onNativeRateChange={this._onRateChange}
onNativeSegmentNotFound={this._onSegmentNotFound}
onNativeTextTrackListEvent={this._onTextTrackListEvent}
onNativeTextTrackEvent={this._onTextTrackEvent}
onNativeMediaTrackListEvent={this._onMediaTrackListEvent}
onNativeMediaTrackEvent={this._onMediaTrackEvent}
onNativeAdEvent={this._onAdEvent}
onNativeTHEOliveEvent={this._onTHEOliveEvent}
onNativeCastEvent={this._onCastEvent}
onNativePresentationModeChange={this._onPresentationModeChange}
onNativeDeviceOrientationChanged={this._onDeviceOrientationChanged}
onNativeResize={this._onResize}
/>
{customPlayerRender ? customPlayerRender({ ...playerProps }) : <THEOplayerRCTView {...playerProps} />}
{posterActive && <Poster uri={poster} style={posterStyle} />}
{children}
</View>
Expand Down
Loading