forked from tanguyantoine/react-native-music-control
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.d.ts
127 lines (111 loc) · 4.04 KB
/
index.d.ts
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
// Type definitions for react-native-music-control
// Project: https://github.com/tanguyantoine/react-native-music-control
// Definitions by: Dao Nam Tien <https://github.com/tiendn>
// TypeScript Version: 2.5.2
type PlayingInfo = {
title: string,
artwork: string, // url
artist: string,
album: string,
genre: string,
duration: number,
description: string,
date: Date,
rating: number
}
type PlaybackInfo = {
state: MusicControl,
elapsedTime: number
}
type ControlEvent = {
// Default false for all.
play: string,
pause: string,
stop: string,
nextTrack: string,
previousTrack: string,
seek: string,
skipForward: string, // options: { interval: number}
skipBackward: string, // options: { interval: number}
seekForward: string, // iOS only. -- Try Sound.setCurrentTime(time: number) react-native-sound
seekBackward: string, // iOS only.
enableLanguageOption: string, // iOS only
disableLanguageOption: string, // iOS only
setRating: string, // Android only.
volume: string, // Android only. Only affected when remoteVolume is enabled
remoteVolume: string // Android only.
closeNotification: string // Android only, options: {when: 'always'||'paused'||'never'}
}
export default class MusicControl {
/**
* Define state status.
*/
static STATE_PLAYING: NativeMusicControl // Playing. Ex: when playing audio again.
static STATE_PAUSED: NativeMusicControl // Paused
static STATE_ERROR: NativeMusicControl // Error
static STATE_STOPPED: NativeMusicControl // Stopped
static STATE_BUFFERING: NativeMusicControl // Buffering
// Rating is not supported on iOS. This is kept here for compatibility
// static RATING_HEART: 0;
// static RATING_THUMBS_UP_DOWN: 0;
// static RATING_3_STARS: 0;
// static RATING_4_STARS: 0;
// static RATING_5_STARS: 0;
// static RATING_PERCENTAGE: 0;
/**
* Backwards compatibility. Use updatePlayback instead.
* @param info
*/
static setPlayback(info: object): void
/**
* Update playback after pause or etc...
* @param info: Object = { state, elapsedTime }
*/
static updatePlayback(info: object): void
/**
* Set enable background mode.
* @param enable
*/
static enableBackgroundMode(enable: boolean): void
/**
* Set now playing
* @param info
*/
static setNowPlaying(info: PlayingInfo): void
/**
* Reset current playing.
*/
static resetNowPlaying(): void
/**
*
* @param controlName :
* @param bool
* @param options // Depends on what event handled.
* Android only supports the intervals 5, 10, & 30, while iOS supports any number
* The interval value only changes what number displays in the UI,
* the actual logic to skip forward or backward by a given amount must be implemented in the appropriate callbacks
*/
static enableControl(eventName: ControlEvent, bool: boolean, options: object ): void
static handleCommand(commandName): void
/**
* Set enable event audio control.
* @param eventName
* @param callback
*/
static on(eventName: ControlEvent, callback: function): void
/**
* Set disable event audio control.
* @param eventName
* @param callback
*/
static off(eventName: ControlEvent, callback: function): void
/**
* It is possible to customize the icon used in the notification on Android.
* By default you can add a drawable resource to your package with the file name music_control_icon
* And the notification will use your custom icon.
* If you need to specify a custom icon name, or change your notification icon during runtime,
* The setNowPlaying function accepts a string for an Android drawable resource name in the notificationIcon prop.
* Keep in mind that just like with music_control_icon the resource specified has to be in the drawable package of your Android app.
*/
// static setCustomNotificationIcon(path: string): void
}