-
Notifications
You must be signed in to change notification settings - Fork 4
/
MusicPlayerFunctions.js
65 lines (58 loc) · 1.53 KB
/
MusicPlayerFunctions.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
import TrackPlayer from "react-native-track-player";
import { setRepeatMode } from "react-native-track-player/lib/trackPlayer";
import { GetPlaybackQuality } from "./LocalStorage/AppSettings";
async function PlayOneSong(song){
await TrackPlayer.reset()
await TrackPlayer.add([song]);
await TrackPlayer.play();
}
async function AddPlaylist (songs){
await TrackPlayer.reset()
await TrackPlayer.add(songs);
await TrackPlayer.play();
}
async function AddSongsToQueue(songs){
await TrackPlayer.add(songs);
}
async function PlaySong(){
await TrackPlayer.play();
}
async function PauseSong(){
await TrackPlayer.pause();
}
async function SetProgressSong(value){
await TrackPlayer.seekTo(value);
}
async function PlayNextSong(){
await TrackPlayer.skipToNext();
PlaySong()
}
async function PlayPreviousSong(){
await TrackPlayer.skipToPrevious();
PlaySong()
}
async function SkipToTrack(trackIndex){
await TrackPlayer.skip(trackIndex);
await PlaySong()
}
async function SetRepeatMode(mode){
await setRepeatMode(mode)
}
async function getIndexQuality(){
const PlaybackQuality = [
{ value: '12kbps' },
{ value: '48kbps' },
{ value: '96kbps' },
{ value: '160kbps' },
{ value: '320kbps' },
];
const data = await GetPlaybackQuality()
let index = 4
PlaybackQuality.map((e, i)=>{
if (e.value === data){
index = i
}
})
return index
}
export {PlayOneSong, PlaySong, PauseSong, SetProgressSong, PlayNextSong, AddPlaylist, PlayPreviousSong, AddSongsToQueue, SkipToTrack,SetRepeatMode, getIndexQuality}