-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.js
81 lines (68 loc) · 1.54 KB
/
index.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
// main index.js
import { NativeModules, NativeEventEmitter } from "react-native";
const { RNDLNA } = NativeModules;
const RNDLNAEmitter = new NativeEventEmitter(RNDLNA);
const EmitterMap = {};
/**
* 启动服务
* @param {*} serverName
*/
export function startDLNAService(serverName) {
if (!RNDLNA.startDLNAService) {
return;
}
RNDLNA.startDLNAService(serverName);
}
/**
* 停止服务
*/
export function stopDLNAService() {
if (!RNDLNA.stopDLNAService) {
return;
}
RNDLNA.stopDLNAService();
}
export function getAllApps(config) {
return RNDLNA.getAllApps(config);
}
export function startApp(packageName) {
RNDLNA.startApp(packageName);
}
export function onDlnaStateChange(callback) {
if (!RNDLNAEmitter || !RNDLNAEmitter.addListener) {
return;
}
EmitterMap["DlnaStateChange"] = RNDLNAEmitter.addListener(
"DlnaStateChange",
callback
);
return EmitterMap["DlnaStateChange"];
}
export function onDlnaMediaInfo(callback) {
if (!RNDLNAEmitter || !RNDLNAEmitter.addListener) {
return;
}
EmitterMap["DlnaMediaInfo"] = RNDLNAEmitter.addListener(
"DlnaMediaInfo",
callback
);
return EmitterMap["DlnaMediaInfo"];
}
export function getDLNAState() {
if (!RNDLNA.getDLNAState) {
return;
}
return RNDLNA.getDLNAState();
}
export const DLNAServiceState = {
IDLE: "IDLE",
STARTING: "STARTING",
RUNNING: "RUNNING",
STOPPING: "STOPPING",
};
export const DLNAMediaType = {
TYPE_UNKNOWN: "TYPE_UNKNOWN",
TYPE_VIDEO: "TYPE_VIDEO",
TYPE_AUDIO: "TYPE_AUDIO",
TYPE_IMAGE: "TYPE_IMAGE",
};