forked from PatrissolJuns/react-native-audio-video-tools
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.d.ts
134 lines (110 loc) · 3.14 KB
/
index.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
/**
* typescript definition
* @author Patrissol Kenfack
*/
declare module "react-native-audio-video-tools" {
import {MediaInformation} from "react-native-ffmpeg";
enum Speed {
SLOW = 'slow',
NORMAL = 'normal',
FAST = 'fast',
}
enum Quality {
LOW = 'low',
HIGH = 'high',
MEDIUM = 'medium',
}
export type MediaDefaultParameters = {
extension?: string;
outputFilePath?: string;
}
export type AdjustVolume = {
rate: number;
} & MediaDefaultParameters;
export type CompressVideo = {
speed?: Speed;
bitrate?: string;
quality?: Quality;
} & MediaDefaultParameters;
export type CompressAudio = {
bitrate?: string;
quality?: Quality;
} & MediaDefaultParameters;
export type ConvertTo = {
extension: string;
outputFilePath?: string;
}
export type CutMedia = {
to: string;
from: string;
outputFilePath?: string;
};
export type CorrectInputFile = {
isCorrect: boolean;
message: string;
}
type AnotherMediaInformation = {
size: number;
width?: number;
height?: number;
filename: string;
extension: string;
isRemoteMedia: null | boolean;
}
export type MediaDetails = MediaInformation & AnotherMediaInformation;
export type MediaDefaultResponse = Promise<{rc: number, outputFilePath: string}>;
class Media {
// Property
isRemoteMedia: null | boolean;
/**
* Update media input file with a full path
*/
setMediaFullPath: (mediaFullPath: string) => void;
/**
* Indicate whether input file is correct or not
* Return object including error message in case input file is incorrect
* @returns {{message: string, isCorrect: boolean}}
*/
isInputFileCorrect: () => Promise<CorrectInputFile>;
/**
* Retrieve details about a video file
*/
getDetails: (force: boolean) => Promise<MediaDetails | any>;
/**
* Convert a video to another extension
*/
convertTo: (options: ConvertTo) => MediaDefaultResponse;
/**
* Cut media
*/
cut: (options: CutMedia) => MediaDefaultResponse;
/**
* Run a command
*/
static execute: (command: string) => Promise<{rc: number}>;
/**
* Cancel ongoing command
*/
static cancel: () => void;
}
export class VideoTools extends Media {
/**
* Compress video
*/
compress: (options: CompressVideo) => MediaDefaultResponse;
/**
* Extract audio from video
*/
extractAudio: (options: MediaDefaultParameters) => MediaDefaultResponse;
}
export class AudioTools extends Media {
/**
* Compress an audio
*/
compress: (options: CompressAudio) => MediaDefaultResponse;
/**
* Adjust volume of an audio
*/
adjustVolume: (options: AdjustVolume) => MediaDefaultResponse;
}
}