forked from tanguyantoine/react-native-music-control
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.d.ts
123 lines (105 loc) · 3.88 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
// 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,
artist: string,
artwork?: string, // url
album?: string,
genre?: string,
duration?: number,
description?: string,
date?: Date,
rating?: number,
color?: any,
notificationIcon?: string
}
type PlaybackInfo = {
state: MusicControl,
elapsedTime: number
}
type ControlEvent = "play" | "pause" | "stop" | "nextTrack" | "previousTrack" | "seek" | "skipForward" | "skipBackward" | "seekForward" | "seekBackward" | "enableLanguageOption" | "disableLanguageOption" | "setRating" | "volume" | "remoteVolume" | "closeNotification";
export default class MusicControl {
/**
* Define state status.
*/
static STATE_PLAYING: string // Playing. Ex: when playing audio again.
static STATE_PAUSED: string // Paused
static STATE_ERROR: string // Error
static STATE_STOPPED: string // Stopped
static STATE_BUFFERING: string // 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
/**
* Disable every audio controls.
*/
static stopControl(): 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
/**
* Switch audio interruption handling.
* When handling is enabled, playback will be paused when application gets interrupted, and resumed after the interruption.
* @param enable
*/
static handleAudioInterruptions(enable: boolean): void
}