-
Notifications
You must be signed in to change notification settings - Fork 10
/
AudioBrowser.js
83 lines (72 loc) · 2.07 KB
/
AudioBrowser.js
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
import React from "react";
import {
StyleSheet,
Text,
Button,
View,
Platform,
NativeModules,
} from "react-native";
const { VideoEditorModule } = NativeModules;
async function applyAudioTrack() {
// Invokes native Video Editor integration module that will apply audio file.
// You can override "VideoEditorModule.applyAudioTrack()" to pass your custom audio data from React Native to Android/iOS.
return await VideoEditorModule.applyAudioTrack();
}
async function discardAudioTrack() {
// Discards previously used audio track
return await VideoEditorModule.discardAudioTrack();
}
async function close() {
// Closes audio browser
return await VideoEditorModule.closeAudioBrowser();
}
// Simple Screen that shows how to pass and apply audio in Video Editor SDK.
// You can implement you own screen with browsing and downloading audio files.
// Audio file MUST BE stored to device storage before using in Video Editor SDK.
export default function AudioBrowser() {
console.log("Start audio browser!!!");
return (
<View style={styles.container}>
<Text style={{ padding: 16, textAlign: "center" }}>
Local audio file is used to demonstrate how to play audio in Video
Editor SDK
</Text>
<View style={{ marginVertical: 16, width: 220 }}>
<Button
title="Apply audio track"
onPress={async () => {
applyAudioTrack();
}}
/>
</View>
<View style={{ marginVertical: 16, width: 220 }}>
<Button
title="Discard audio track"
color="#f44339"
onPress={async () => {
discardAudioTrack();
}}
/>
</View>
<View style={{ marginVertical: 16, width: 220 }}>
<Button
title="Close"
color="#9e9e9e"
onPress={async () => {
close();
}}
/>
</View>
</View>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: "#fff",
marginVertical: 16,
alignItems: "center",
justifyContent: "center",
},
});