Skip to content

Commit

Permalink
Merge pull request #23 from THEOplayer/release/v0.6.0
Browse files Browse the repository at this point in the history
Release/v0.6.0
  • Loading branch information
wjoosen authored Mar 27, 2024
2 parents 0adf0fc + a17ab7a commit cb78ad6
Show file tree
Hide file tree
Showing 7 changed files with 56 additions and 19 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

## [0.6.0] - 24-03-27

### Fixed

- Fixed an issue where the skip buttons would remain disabled for MP4 sources.

## [0.5.0] - 24-03-06

### Added
Expand Down
3 changes: 2 additions & 1 deletion doc/limitations.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
## Limitations and Known Issues

- Support for remote control navigation on TV platforms.
- Ad UI support
- Mobile Ad UI customization
- Interaction with Google IMA elements on web
- TextTrack styling
31 changes: 30 additions & 1 deletion doc/ui.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,22 @@ The available UI components with their documentation can be found [here](../src/
### Creating your own custom UI

All components inside the `DefaultTHEOplayerUi` are available through the `react-native-theoplayer` package and can
be use these to create your own custom layout. Since `DefaultTHEOplayerUi` is our version of a "custom" UI, you could
be used to create your own custom layout. Since `DefaultTHEOplayerUi` is our version of a "custom" UI, you could
use this as a starting point for your own custom layout.

This use-case is implemented in the [example app](https://github.com/THEOplayer/react-native-theoplayer/blob/develop/doc/example-app.md)
that is included in the `react-native-theoplayer` repository, which adds a
custom [SourceMenuButton](https://github.com/THEOplayer/react-native-theoplayer/blob/develop/example/src/custom/SourceMenuButton.tsx).

During ad playback the UI probably needs to be different compared to during content. This can include disabling seeking,
showing the ad break duration and when the user can skip to content.

Similarly to content playback, the ad UI can be customized by adding components to their respective
slots: `adTop`, `adCenter` and `adBottom`.

The customized ad UI is only available for web at this moment. Android and iOS will have a play/pause interaction
in the middle of the screen together with the default Google IMA ad layout.

The following example shows a UI layout with only basic playback controls:

```tsx
Expand Down Expand Up @@ -110,6 +119,26 @@ export default function App() {
</ControlBar>
</>
}
adTop={
<ControlBar>
<AdClickThroughButton />
</ControlBar>
}
adCenter={<CenteredControlBar middle={<PlayButton />} />}
adBottom={
<>
<ControlBar style={{justifyContent: 'flex-start'}}>
<AdDisplay />
<AdCountdown />
<Spacer />
<AdSkipButton />
</ControlBar>
<ControlBar>
<MuteButton />
<SeekBar />
</ControlBar>
</>
}
/>
)}
</THEOplayerView>
Expand Down
14 changes: 4 additions & 10 deletions example/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -132,17 +132,11 @@ export default function App() {
</>
}
adTop={
<>
<ControlBar>
<AdClickThroughButton />
</ControlBar>
</>
}
adCenter={
<>
<CenteredControlBar middle={<PlayButton />} />
</>
<ControlBar>
<AdClickThroughButton />
</ControlBar>
}
adCenter={<CenteredControlBar middle={<PlayButton />} />}
adBottom={
<>
<ControlBar style={{justifyContent: 'flex-start'}}>
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@theoplayer/react-native-ui",
"version": "0.5.0",
"version": "0.6.0",
"description": "A React Native UI for @theoplayer/react-native",
"main": "lib/commonjs/index",
"module": "lib/module/index",
Expand Down
15 changes: 11 additions & 4 deletions src/ui/components/button/SkipButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,17 +48,24 @@ export class SkipButton extends PureComponent<SkipButtonProps, SkipButtonState>

componentDidMount() {
const player = (this.context as UiContext).player;
player.addEventListener(PlayerEventType.PROGRESS, this.onTimeupdate);
player.addEventListener(PlayerEventType.PROGRESS, this.onProgress);
player.addEventListener(PlayerEventType.PLAYING, this.onPlaying);
this.setState({ enabled: player.seekable.length > 0 });
}

componentWillUnmount() {
const player = (this.context as UiContext).player;
player.removeEventListener(PlayerEventType.PROGRESS, this.onTimeupdate);
player.removeEventListener(PlayerEventType.PROGRESS, this.onProgress);
player.removeEventListener(PlayerEventType.PLAYING, this.onPlaying);
}

private readonly onTimeupdate = (event: ProgressEvent) => {
this.setState({ enabled: event.seekable.length > 0 });
private readonly onProgress = (event: ProgressEvent) => {
this.setState({ enabled: event.seekable.length > 0 || event.buffered.length > 0 });
};

private readonly onPlaying = () => {
const player = (this.context as UiContext).player;
this.setState({ enabled: player.seekable.length > 0 || player.buffered.length > 0 });
};

private readonly onPress = () => {
Expand Down

0 comments on commit cb78ad6

Please sign in to comment.