-
Notifications
You must be signed in to change notification settings - Fork 63
/
Copy pathUtils.js
executable file
·70 lines (61 loc) · 1.23 KB
/
Utils.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
/*
* @Descripttion: 工具类
* @Author: huangjun
* @Date: 2020-09-16 11:31:07
* @LastEditors: huangjun
* @LastEditTime: 2020-09-16 11:33:56
*/
'use strict';
import {NativeModules, Platform, NetInfo} from 'react-native';
const {RNNeteaseIm, PinYin} = NativeModules;
class Utils {
/**
* 清除数据缓存
*/
cleanCache() {
return RNNeteaseIm.cleanCache();
}
/**
* 获取缓存大小
*/
getCacheSize() {
return RNNeteaseIm.getCacheSize();
}
/**
* 播放录音
* @returns {*}
*/
play(filepath) {
return RNNeteaseIm.play(filepath);
}
/**
* 播放本地资源音乐
* name:iOS:文件名字,Android:文件路径
* type:音乐类型,如:'mp3'
* @returns {*}
*/
playLocacl(name, type) {
if (Platform.OS === 'ios') {
return RNNeteaseIm.playLocal(name, type);
}
return RNNeteaseIm.playLocal('assets:///' + name + '.' + type, type);
}
/**
* 停止播放录音
* @returns {*}
*/
stopPlay() {
return RNNeteaseIm.stopPlay();
}
sortPinYin(o, key) {
return PinYin.sortPinYin(o, key);
}
/**
* 仅限Android
* @returns {*}
*/
fetchNetInfo() {
return RNNeteaseIm.fetchNetInfo();
}
}
export default new Utils();