UNPKG

3.69 kBTypeScriptView Raw
1import { Observable } from 'rxjs/Observable';
2export interface MusicControlsOptions {
3 track: string;
4 artist: string;
5 cover: string;
6 isPlaying: boolean;
7 dismissable: boolean;
8 hasPrev: boolean;
9 hasNext: boolean;
10 hasClose: boolean;
11 ticker: string;
12}
13/**
14 * @name MusicControls
15 * @description
16 * Music controls for Cordova applications.
17 * Display a 'media' notification with play/pause, previous, next buttons, allowing the user to control the play.
18 * Handle also headset event (plug, unplug, headset button).
19 *
20 * @usage
21 * ```
22 * import {MusicControls} from 'ionic-native';
23 *
24 * MusicControls.create({
25 * track : 'Time is Running Out', // optional, default : ''
26 * artist : 'Muse', // optional, default : ''
27 * cover : 'albums/absolution.jpg', // optional, default : nothing
28 * // cover can be a local path (use fullpath 'file:///storage/emulated/...', or only 'my_image.jpg' if my_image.jpg is in the www folder of your app)
29 * // or a remote url ('http://...', 'https://...', 'ftp://...')
30 * isPlaying : true, // optional, default : true
31 * dismissable : true, // optional, default : false
32 *
33 * // hide previous/next/close buttons:
34 * hasPrev : false, // show previous button, optional, default: true
35 * hasNext : false, // show next button, optional, default: true
36 * hasClose : true, // show close button, optional, default: false
37 *
38 * // Android only, optional
39 * // text displayed in the status bar when the notification (and the ticker) are updated
40 * ticker : 'Now playing "Time is Running Out"'
41 * });
42 *
43 * MusicControls.subscribe().subscribe(action => {
44 *
45 * switch(action) {
46 * case 'music-controls-next':
47 * // Do something
48 * break;
49 * case 'music-controls-previous':
50 * // Do something
51 * break;
52 * case 'music-controls-pause':
53 * // Do something
54 * break;
55 * case 'music-controls-play':
56 * // Do something
57 * break;
58 * case 'music-controls-destroy':
59 * // Do something
60 * break;
61 *
62 * // Headset events (Android only)
63 * case 'music-controls-media-button' :
64 * // Do something
65 * break;
66 * case 'music-controls-headset-unplugged':
67 * // Do something
68 * break;
69 * case 'music-controls-headset-plugged':
70 * // Do something
71 * break;
72 * default:
73 * break;
74 * }
75 *
76 * });
77 *
78 * MusicControls.listen(); // activates the observable above
79 *
80 * MusicControls.updateIsPlaying(true);
81 *
82 *
83 * ```
84 * @interfaces
85 * MusicControlsOptions
86 */
87export declare class MusicControls {
88 /**
89 * Create the media controls
90 * @param options {MusicControlsOptions}
91 * @returns {Promise<any>}
92 */
93 static create(options: MusicControlsOptions): Promise<any>;
94 /**
95 * Destroy the media controller
96 * @returns {Promise<any>}
97 */
98 static destroy(): Promise<any>;
99 /**
100 * Subscribe to the events of the media controller
101 * @returns {Observable<any>}
102 */
103 static subscribe(): Observable<any>;
104 /**
105 * Start listening for events, this enables the Observable from the subscribe method
106 */
107 static listen(): void;
108 /**
109 * Toggle play/pause:
110 * @param isPlaying {boolean}
111 */
112 static updateIsPlaying(isPlaying: boolean): void;
113}