UNPKG

5.05 kBJavaScriptView Raw
1"use strict";
2var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3 var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4 if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5 else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6 return c > 3 && r && Object.defineProperty(target, key, r), r;
7};
8var plugin_1 = require('./plugin');
9/**
10 * @name MusicControls
11 * @description
12 * Music controls for Cordova applications.
13 * Display a 'media' notification with play/pause, previous, next buttons, allowing the user to control the play.
14 * Handle also headset event (plug, unplug, headset button).
15 *
16 * @usage
17 * ```
18 * import {MusicControls} from 'ionic-native';
19 *
20 * MusicControls.create({
21 * track : 'Time is Running Out', // optional, default : ''
22 * artist : 'Muse', // optional, default : ''
23 * cover : 'albums/absolution.jpg', // optional, default : nothing
24 * // 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)
25 * // or a remote url ('http://...', 'https://...', 'ftp://...')
26 * isPlaying : true, // optional, default : true
27 * dismissable : true, // optional, default : false
28 *
29 * // hide previous/next/close buttons:
30 * hasPrev : false, // show previous button, optional, default: true
31 * hasNext : false, // show next button, optional, default: true
32 * hasClose : true, // show close button, optional, default: false
33 *
34 * // Android only, optional
35 * // text displayed in the status bar when the notification (and the ticker) are updated
36 * ticker : 'Now playing "Time is Running Out"'
37 * });
38 *
39 * MusicControls.subscribe().subscribe(action => {
40 *
41 * switch(action) {
42 * case 'music-controls-next':
43 * // Do something
44 * break;
45 * case 'music-controls-previous':
46 * // Do something
47 * break;
48 * case 'music-controls-pause':
49 * // Do something
50 * break;
51 * case 'music-controls-play':
52 * // Do something
53 * break;
54 * case 'music-controls-destroy':
55 * // Do something
56 * break;
57 *
58 * // Headset events (Android only)
59 * case 'music-controls-media-button' :
60 * // Do something
61 * break;
62 * case 'music-controls-headset-unplugged':
63 * // Do something
64 * break;
65 * case 'music-controls-headset-plugged':
66 * // Do something
67 * break;
68 * default:
69 * break;
70 * }
71 *
72 * });
73 *
74 * MusicControls.listen(); // activates the observable above
75 *
76 * MusicControls.updateIsPlaying(true);
77 *
78 *
79 * ```
80 * @interfaces
81 * MusicControlsOptions
82 */
83var MusicControls = (function () {
84 function MusicControls() {
85 }
86 /**
87 * Create the media controls
88 * @param options {MusicControlsOptions}
89 * @returns {Promise<any>}
90 */
91 MusicControls.create = function (options) { return; };
92 /**
93 * Destroy the media controller
94 * @returns {Promise<any>}
95 */
96 MusicControls.destroy = function () { return; };
97 /**
98 * Subscribe to the events of the media controller
99 * @returns {Observable<any>}
100 */
101 MusicControls.subscribe = function () { return; };
102 /**
103 * Start listening for events, this enables the Observable from the subscribe method
104 */
105 MusicControls.listen = function () { };
106 /**
107 * Toggle play/pause:
108 * @param isPlaying {boolean}
109 */
110 MusicControls.updateIsPlaying = function (isPlaying) { };
111 __decorate([
112 plugin_1.Cordova()
113 ], MusicControls, "create", null);
114 __decorate([
115 plugin_1.Cordova()
116 ], MusicControls, "destroy", null);
117 __decorate([
118 plugin_1.Cordova({
119 observable: true
120 })
121 ], MusicControls, "subscribe", null);
122 __decorate([
123 plugin_1.Cordova({ sync: true })
124 ], MusicControls, "listen", null);
125 __decorate([
126 plugin_1.Cordova({ sync: true })
127 ], MusicControls, "updateIsPlaying", null);
128 MusicControls = __decorate([
129 plugin_1.Plugin({
130 pluginName: 'MusicControls',
131 plugin: 'cordova-plugin-music-controls',
132 pluginRef: 'MusicControls',
133 repo: 'https://github.com/homerours/cordova-music-controls-plugin'
134 })
135 ], MusicControls);
136 return MusicControls;
137}());
138exports.MusicControls = MusicControls;
139//# sourceMappingURL=music-controls.js.map
\No newline at end of file