Skip to content

Commit d8108b1

Browse files
committed
fix: added tintColor and updated readme
1 parent dc59fe5 commit d8108b1

File tree

8 files changed

+87
-25
lines changed

8 files changed

+87
-25
lines changed

.github/workflows/ci.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,3 +62,24 @@ jobs:
6262
- name: Build example for Web
6363
run: |
6464
yarn example expo export --platform web
65+
66+
publish-npm:
67+
needs: [build-library, test]
68+
runs-on: ubuntu-latest
69+
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
70+
steps:
71+
- name: Checkout
72+
uses: actions/checkout@v3
73+
74+
- name: Setup
75+
uses: ./.github/actions/setup
76+
77+
- name: Build package
78+
run: yarn prepare
79+
80+
- name: Publish to npm
81+
run: |
82+
npm config set //registry.npmjs.org/:_authToken=${NPM_TOKEN}
83+
npm publish --access public
84+
env:
85+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

README.md

Lines changed: 52 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# react-native-video-trimmer-ui
22

3-
React Native Video Trimmer is a powerful and easy-to-use component that adds video trimming functionality to your React Native applications. Perfect for video editing apps, social media platforms, or any application requiring video manipulation.
3+
React Native Video Trimmer UI is a powerful and easy-to-use UI component that adds video trimming functionality to your React Native applications. It's perfect for video editing apps, social media platforms, or any application requiring video manipulation.
44

55
## Key Features
66

@@ -10,9 +10,7 @@ React Native Video Trimmer is a powerful and easy-to-use component that adds vid
1010
- Support for various video formats
1111
- Efficient trimming process with optimized performance
1212
- Cross-platform compatibility (iOS and Android)
13-
- Easy integration with existing React Native projects
14-
15-
This library leverages native video processing capabilities to ensure smooth performance and high-quality output.
13+
- Easy integration with existing React Native projects (Expo and bare React Native)
1614

1715
## Installation
1816

@@ -22,30 +20,74 @@ npm install react-native-video react-native-video-trimmer-ui
2220

2321
## Usage
2422

23+
Import the VideoTrimmerUI component in your React Native application:
24+
2525
```javascript
26-
import VideoTrimmer from 'react-native-video-trimmer';
26+
import VideoTrimmerUI from 'react-native-video-trimmer-ui';
27+
```
2728

28-
// ...
29+
Then, use the VideoTrimmerUI component in your JSX:
2930

30-
<VideoTrimmer source={videoSource} />
31+
```javascript
32+
<VideoTrimmerUI
33+
source={{ uri: 'https://example.com/video.mp4' }}
34+
onSelected={(start, end) => console.log(`Selected trim range: ${start} to ${end}`)}
35+
loop={true}
36+
containerStyle={{ height: 300 }}
37+
sliderContainerStyle={{ marginHorizontal: 20 }}
38+
tintColor="#007AFF"
39+
/>
3140
```
3241

33-
## Props
42+
### Props
3443

3544
| Prop | Type | Default | Description |
3645
|------|------|---------|-------------|
3746
| source | ReactVideoSource | required | The source of the video (e.g., `{ uri: 'https://example.com/video.mp4' }`) |
47+
| onSelected | function | - | Callback function that receives the selected start and end times (in seconds) when the user finishes trimming |
3848
| loop | boolean | true | Whether the video should loop after reaching the end |
39-
| containerStyle | ViewStyle | - | Custom styles for the container of the VideoWithSlider component |
49+
| containerStyle | ViewStyle | - | Custom styles for the container of the VideoTrimmerUI component |
4050
| sliderContainerStyle | ViewStyle | - | Custom styles for the slider container |
41-
| tintColor | string | '#24a0ed' | Color of the slider and its components |
51+
| tintColor | string | '#24A0ED' | Color of the slider and its components |
52+
53+
### Methods
54+
55+
You can access the VideoTrimmerUI methods using a ref:
56+
57+
```javascript
58+
const trimmerRef = useRef(null);
59+
60+
// Later in your component
61+
const [start, end] = trimmerRef.current.getSelection();
62+
console.log(`Current trim range: ${start} to ${end}`);
63+
64+
// In your JSX
65+
<VideoTrimmerUI
66+
ref={trimmerRef}
67+
// ... other props
68+
/>
69+
```
70+
71+
Available methods:
72+
- `getSelection()`: Returns an array with the current start and end times of the trim range.
73+
74+
75+
## Trimming the Video
76+
77+
After selecting the trim range using the VideoTrimmerUI component, you can use the `react-native-video-trimmer-core` library to perform the actual video trimming. For more information on how to use this library, please refer to the [react-native-video-trimmer-core npm package](https://www.npmjs.com/package/react-native-video-trimmer-core).
4278

4379
## Features
4480

4581
- Video trimming functionality for React Native applications
4682
- Customizable slider for selecting trim range
4783
- Supports looping video playback
4884

85+
## Upcoming Features
86+
87+
- Additional customization options for the trimmer UI
88+
- Fully customizable Video
89+
- Fully customizable slider
90+
4991
## License
5092

5193
MIT

example/src/App.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import { StyleSheet, View } from 'react-native';
2-
import VideoTrimmer from 'react-native-video-trimmer-ui';
2+
import VideoTrimmerUI from 'react-native-video-trimmer-ui';
33

44
export default function App() {
55
return (
66
<View style={styles.container}>
7-
<VideoTrimmer
7+
<VideoTrimmerUI
88
source={require('../assets/sample.mp4')}
99
onSelected={console.info}
1010
/>

src/components/ProgressBar.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,16 @@ import { progressBarStyles } from './styles';
44
interface ProgressBarProps {
55
value: number;
66
style?: StyleProp<ViewStyle>;
7+
tintColor: string | undefined;
78
}
89

9-
function ProgressBar({ value, style }: ProgressBarProps) {
10+
function ProgressBar({ value, style, tintColor }: ProgressBarProps) {
1011
return (
1112
<View style={[progressBarStyles.container, style]}>
1213
<View
1314
style={[
1415
progressBarStyles.progress,
15-
{ width: `${Math.ceil(100 * value)}%` },
16+
{ width: `${Math.ceil(100 * value)}%`, backgroundColor: tintColor },
1617
]}
1718
/>
1819
</View>

src/components/Slider.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ function Slider({
3535
])}
3636
minimumTrackTintColor={tintColor}
3737
renderMinimumTrackComponent={() => (
38-
<ProgressBar value={playbackTime / thumbs[1]} />
38+
<ProgressBar value={playbackTime / thumbs[1]} tintColor={tintColor} />
3939
)}
4040
onSlidingComplete={onSlidingComplete}
4141
renderThumbComponent={() => (

src/components/VideoTrimmer.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@ export interface VideoTrimmerProps {
1919
}
2020

2121
export interface VideoTrimmerRef {
22-
getThumbs: () => [number, number];
22+
getSelection: () => [number, number];
2323
}
2424

25-
function VideoTrimmer(props: VideoTrimmerProps, ref: Ref<unknown>) {
25+
function VideoTrimmerUI(props: VideoTrimmerProps, ref: Ref<unknown>) {
2626
const {
2727
containerStyle,
2828
source,
@@ -36,9 +36,9 @@ function VideoTrimmer(props: VideoTrimmerProps, ref: Ref<unknown>) {
3636
const [thumbs, setThumbs] = useState<[number, number]>([0, 0]);
3737
const videoRef = React.useRef<VideoRef | null>(null);
3838

39-
const getThumbs = () => thumbs;
39+
const getSelection = () => thumbs;
4040
React.useImperativeHandle(ref, () => ({
41-
getThumbs,
41+
getSelection,
4242
}));
4343

4444
const seek = (time: number | undefined) => {
@@ -113,4 +113,4 @@ function VideoTrimmer(props: VideoTrimmerProps, ref: Ref<unknown>) {
113113
);
114114
}
115115

116-
export default forwardRef(VideoTrimmer);
116+
export default forwardRef(VideoTrimmerUI);

src/components/styles.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,8 @@ export const sliderStyles = StyleSheet.create({
4040
});
4141

4242
export const progressBarStyles = StyleSheet.create({
43-
container: { flex: 1, backgroundColor: 'transparent' },
43+
container: { flex: 1, backgroundColor: '#00000050' },
4444
progress: {
4545
flex: 1,
46-
opacity: 0.5,
47-
backgroundColor: 'black',
4846
},
4947
});

src/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
import VideoTrimmer from './components/VideoTrimmer';
1+
import VideoTrimmerUI from './components/VideoTrimmer';
22

3-
export default VideoTrimmer;
3+
export default VideoTrimmerUI;

0 commit comments

Comments
 (0)