-
Notifications
You must be signed in to change notification settings - Fork 323
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(Processing): Provided standalone APIs
- Loading branch information
Shahen Hovhannisyan
committed
Mar 17, 2017
1 parent
18d015c
commit c853b2e
Showing
10 changed files
with
290 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
[ignore] | ||
./node_modules | ||
[include] | ||
./lib | ||
[libs] | ||
|
||
[options] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
// @flow | ||
|
||
import { NativeModules } from 'react-native'; | ||
import type { | ||
sourceType, | ||
trimOptions | ||
} from './types'; | ||
|
||
import { getActualSource } from '../utils'; | ||
|
||
const { RNTrimmerManager: TrimmerManager } = NativeModules; | ||
class ProcessingManager { | ||
static trim(source: sourceType, options: trimOptions): Promise<string> { | ||
const actualSource: string = getActualSource(source); | ||
const mData = { source: actualSource, ...options }; | ||
return TrimmerManager.trim(mData) | ||
.then((res) => res.source); | ||
} | ||
static compress(source: sourceType, options: any): Promise<*> { | ||
const actualSource: string = getActualSource(source); | ||
const mData = { source: actualSource, ...options }; | ||
return TrimmerManager.compress(mData); | ||
} | ||
static getVideoInfo(source: sourceType): Promise<*> { | ||
const actualSource: string = getActualSource(source); | ||
return TrimmerManager.getVideoInfo(actualSource); | ||
} | ||
static getPreviewForSecond(source: sourceType, second: number): Promise<*> { | ||
const actualSource: string = getActualSource(source); | ||
const mData = { source: actualSource, second }; | ||
return TrimmerManager.getPreviewImageAtPosition(mData) | ||
.then((res) => res.image); | ||
} | ||
} | ||
|
||
export default ProcessingManager; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
// @flow | ||
|
||
|
||
import { NativeModules } from 'react-native'; | ||
import { getActualSource } from '../utils'; | ||
const { RNVideoTrimmer } = NativeModules; | ||
import type { | ||
compressOptions, | ||
previewMaxSize, | ||
sourceType, | ||
trimOptions, | ||
} from './types'; | ||
|
||
export class ProcessingManager { | ||
static trim(source: sourceType, options: trimOptions = {}) { | ||
const actualSource: string = getActualSource(source); | ||
return new Promise((resolve, reject) => { | ||
RNVideoTrimmer.trim(actualSource, options, (err: Object<*>, output: string) => { | ||
if (err) { | ||
return reject(err); | ||
} | ||
return resolve(output); | ||
}); | ||
}); | ||
}; | ||
static getPreviewForSecond( | ||
source: sourceType, | ||
forSecond: ?number = 0, | ||
maximumSize: previewMaxSize | ||
) { | ||
const actualSource: string = getActualSource(source); | ||
return new Promise((resolve, reject) => { | ||
RNVideoTrimmer.getPreviewImageAtPosition(actualSource, forSecond, maximumSize, | ||
(err: Object<*>, base64: string) => { | ||
if (err) { | ||
return reject(err); | ||
} | ||
return resolve(base64); | ||
}); | ||
}); | ||
} | ||
static getVideoInfo(source: sourceType) { | ||
const actualSource: string = getActualSource(source); | ||
return new Promise((resolve, reject) => { | ||
RNVideoTrimmer.getAssetInfo(actualSource, (err, info) => { | ||
if (err) { | ||
return reject(err); | ||
} | ||
return resolve(info); | ||
}); | ||
}); | ||
} | ||
static compress(source: sourceType, _options: compressOptions) { | ||
const options = { ..._options }; | ||
const actualSource = getActualSource(source); | ||
return new Promise((resolve, reject) => { | ||
RNVideoTrimmer.compress(actualSource, options, (err, output) => { | ||
if (err) { | ||
return reject(err); | ||
} | ||
return resolve(output); | ||
}); | ||
}); | ||
} | ||
} | ||
|
||
export default ProcessingManager; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export ProcessingManager from './ProcessingManager'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// @flow | ||
|
||
export type sourceType = string | ||
| { uri: string }; | ||
|
||
export type trimOptions = { | ||
startTime: number, | ||
endTime: number | ||
}; | ||
|
||
declare class RNTrimmerManager { | ||
static trim(source: string, options: trimOptions): Promise<{ source: string }>; | ||
static compress(source: string, options: any): Promise<*>; | ||
static getVideoInfo(source: string): Promise<*>; | ||
static getPreviewImages(source: string): Promise<*>; | ||
static getPreviewImageAtPosition(source: string, second: number): Promise<{ image: string }>; | ||
} |
Oops, something went wrong.