Skip to content

Commit

Permalink
Merge pull request TheWidlarzGroup#199 from moskalakamil/feat/docs
Browse files Browse the repository at this point in the history
  • Loading branch information
moskalakamil authored Dec 3, 2024
2 parents ae12526 + f163b07 commit 6748d1c
Show file tree
Hide file tree
Showing 38 changed files with 15,631 additions and 6,663 deletions.
4 changes: 2 additions & 2 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Since this is a volunteer project and is very active, anything you can do to red
The following steps will help get your PR merged quickly:
- Update the documentation
If you've added new functionality, update the README.md with an entry for your prop or event.
If you've added new functionality, update the documentation with an entry for your prop or event.
The entry should be inserted in alphabetical order.
- Provide an example of how to test the change
Expand All @@ -22,4 +22,4 @@ Add a note describing what your PR does. If there is a change to the behavior of

### Changes

## Test plan
## Test plan
38 changes: 38 additions & 0 deletions .github/workflows/deploy-docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Deploy Documentation

on:
workflow_dispatch:
branches:
- master
paths:
- '.github/workflows/deploy-docs.yml'
- 'docs/**'
jobs:
build_and_deploy_docs:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
submodules: recursive

- name: Setup
uses: ./.github/actions/setup
with:
github_token: ${{ secrets.GITHUB_TOKEN }}

- name: Build Documentation
run: |
cd docs
yarn install
yarn build
- name: Deploy to GitHub Pages
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./docs/build
user_name: github-actions[bot]
user_email: 41898282+github-actions[bot]@users.noreply.github.com
permissions:
contents: write
73 changes: 10 additions & 63 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ As we approach the end of 2024, we've started working on the roadmap for this pr

# react-native-video-player

🎬 `<VideoPlayer />` component for React Native with a few controls. This player uses
🎥 `<VideoPlayer />` component for React Native with a few controls. This player uses
[react-native-video](https://github.com/TheWidlarzGroup/react-native-video) under the hood

https://github.com/user-attachments/assets/1bbec058-4f4c-4ab0-9f14-1454c901b474
Expand Down Expand Up @@ -49,74 +49,21 @@ pod install
/>
```

## Documentation

| Prop | Description |
|-------------------------|----------------------------------------------------------------------------------------------------------------------------------------------|
| source | The video source to pass to react-native-video. |
| thumbnail | An Image source to use as thumbnail before the video gets loaded. |
| endThumbnail | An Image source to use as thumbnail after the video has ended. |
| videoWidth | Width of the video to calculate the player size. |
| videoHeight | Height of the video to calculate the player size. |
| duration | Duration should always be set out of the box. if not, you can use this prop |
| showDuration | Show duration in seek bar. |
| autoplay | Start the video automatically. |
| defaultMuted | Start the video muted, but allow toggling. |
| muted | Start the video muted and hide the mute toggle button. |
| controlsTimeout | Timeout when to hide the controls. |
| disableControlsAutoHide | Disable auto hiding the controls. |
| disableFullscreen | Disable the fullscreen button. |
| repeat | Loop the video after playback is done. |
| resizeMode | The video's resizeMode. defaults to contain and is passed to react-native-video. |
| hideControlsOnStart | Hides the controls on start video. |
| endWithThumbnail | Returns to the thumbnail after the video ends. If an `endThumbnail` image is not specified then the image specified in `thumbnail` is shown. |
| disableSeek | Disable video seeking. |
| pauseOnPress | Automatically pause/play when pressing the video player anywhere. |
| fullScreenOnLongPress | Automatically show video on fullscreen when doing a long press. |
| onStart | Callback for when the start button is pressed. |
| onPlayPress | Callback for when the play button is pressed. |
| onHideControls | Callback for when the controls are being hide. |
| onShowControls | Callback for when the controls are being shown. |
| customStyles | The player can be customized in this object, see customStyles for the options. |

All other props are passed to the react-native-video component.

### customStyles

- wrapper
- video
- controls
- playControl
- controlButton
- controlIcon
- playIcon
- seekBar
- seekBarFullWidth
- seekBarProgress
- seekBarKnob
- seekBarBackground
- thumbnail
- playButton
- playArrow
- videoWrapper

### Ref methods

| Method | Props | Description |
|-------------------------|-----------------|---------------------------------------------------------------------------|
| seek | time: float | Seek the player to the given time. |
| stop | | Stop the playback and reset back to 0:00. |
| pause | | Pause the playback. |
| resume | | Resume the playback. |

## Future features

Check out our [Roadmap](https://github.com/TheWidlarzGroup/react-native-video-player/discussions/186) for what's coming up next! We're always working on new features and improvements, so stay tuned!

## Community support
We have an discord server where you can ask questions and get help. [Join the discord server](https://discord.gg/WXuM4Tgb9X)
We have a discord server where you can ask questions and get help. [Join the discord server](https://discord.gg/WXuM4Tgb9X)

## Enterprise Support
<p>
📱 <i>react-native-video-player</i> is provided <i>as it is</i>. For enterprise support or other business inquiries, <a href="https://www.thewidlarzgroup.com/?utm_source=rnv&utm_medium=readme#Contact">please contact us 🤝</a>. We can help you with the integration, customization and maintenance. We are providing both free and commercial support for this project. let's build something awesome together! 🚀
📱 <i>react-native-video-player</i> is provided <i>as it is</i>. For enterprise support or other business inquiries, <a href="https://www.thewidlarzgroup.com/?utm_source=rnvp&utm_medium=readme#Contact">please contact us 🤝</a>. We can help you with the integration, customization and maintenance. We are providing both free and commercial support for this project. let's build something awesome together! 🚀
</p>
<a href="https://www.thewidlarzgroup.com/?utm_source=rnvp&utm_medium=readme">
<picture>
<source media="(prefers-color-scheme: dark)" srcset="./docs/static/img/banners/twg-dark.png" />
<source media="(prefers-color-scheme: light)" srcset="./docs/static/img/banners/twg-light.png" />
<img alt="TheWidlarzGroup" src="./docs/static/img/banners/twg-light.png" />
</picture>
</a>
20 changes: 20 additions & 0 deletions docs/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Dependencies
/node_modules

# Production
/build

# Generated files
.docusaurus
.cache-loader

# Misc
.DS_Store
.env.local
.env.development.local
.env.test.local
.env.production.local

npm-debug.log*
yarn-debug.log*
yarn-error.log*
41 changes: 41 additions & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Website

This website is built using [Docusaurus](https://docusaurus.io/), a modern static website generator.

### Installation

```
$ yarn
```

### Local Development

```
$ yarn start
```

This command starts a local development server and opens up a browser window. Most changes are reflected live without having to restart the server.

### Build

```
$ yarn build
```

This command generates static content into the `build` directory and can be served using any static contents hosting service.

### Deployment

Using SSH:

```
$ USE_SSH=true yarn deploy
```

Not using SSH:

```
$ GIT_USER=<Your GitHub username> yarn deploy
```

If you are using GitHub pages for hosting, this command is a convenient way to build the website and push to the `gh-pages` branch.
61 changes: 61 additions & 0 deletions docs/docs/api/events.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# API - Events

The `react-native-video-player` component exposes a set of events that allow you to interact with and control the video playback. Below, you’ll find a detailed list of these events, their descriptions, and how to use them. These events give you full flexibility to customize the behavior of the video player.

---

## Component Events

### `onStart`
- **Type**: `function`
- **Description**: Callback function triggered when the start button is pressed.
- **Example**:
```
onStart={() => {
console.log('Video started!');
}}
```

---

### `onPlayPress`
- **Type**: `function`
- **Description**: Callback function triggered when the play button is pressed.
- **Example**:
```
onPlayPress={() => {
console.log('Play button pressed!');
}}
```

---

### `onHideControls`
- **Type**: `function`
- **Description**: Callback function triggered when the video controls are hidden.
- **Example**:
```
onHideControls={() => {
console.log('Controls are hidden.');
}}
```

---

### `onShowControls`
- **Type**: `function`
- **Description**: Callback function triggered when the video controls are shown.
- **Example**:
```
onShowControls={() => {
console.log('Controls are shown.');
}}
```

---

## Additional Events from `react-native-video`

The `react-native-video-player` component also supports all events from the underlying [react-native-video](https://github.com/TheWidlarzGroup.com/react-native-video) library. These include events like `onLoad`, `onError`, `onEnd`, and more.

For a full list of events and how to use them, refer to the [react-native-video events documentation](https://docs.thewidlarzgroup.com/react-native-video/component/events).
75 changes: 75 additions & 0 deletions docs/docs/api/methods.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
# API - Methods

The `react-native-video-player` component exposes some methods through a ref. These methods provide direct control over video playback, allowing you to customize and manage the player programmatically.

---

## Using Ref Methods

To access the methods, you need to create a ref for the `VideoPlayer` component. Here's an example of how to set up a ref and use the available methods:

```tsx
import React, {useRef} from 'react';
import VideoPlayer, {type VideoPlayerRef} from 'react-native-video-player';

const App = () => {
const playerRef = useRef<VideoPlayerRef>(null);

const handlePause = () => {
playerRef.current?.pause();
};

return (
<VideoPlayer
ref={playerRef}
source={{ uri: 'https://example.com/video.mp4' }}
/>
);
};
```

---

## Available Methods

### `seek(time)`
- **Description**: Moves the video playback to the specified `time` (in seconds).
- **Parameters**:
- `time` (number): The time in seconds to which the player should seek.
- **Example**:
```ts
playerRef.current?.seek(30); // Seeks to the 30th second
```

---

### `pause()`
- **Description**: Pauses the video playback.
- **Example**:
```ts
playerRef.current?.pause();
```

---

### `resume()`
- **Description**: Resumes video playback from the current position.
- **Example**:
```ts
playerRef.current?.resume();
```

---

### `stop()`
- **Description**: Stops the video playback and resets it to the beginning.
- **Example**:
```ts
playerRef.current?.stop();
```

---

The `react-native-video-player` component also supports all methods from the underlying [react-native-video](https://github.com/TheWidlarzGroup.com/react-native-video) library. These include methods like `save`, `setFullScreen`, and more.

For a full list of methods and how to use them, refer to the [react-native-video methods documentation](https://docs.thewidlarzgroup.com/react-native-video/component/methods).
Loading

0 comments on commit 6748d1c

Please sign in to comment.