|
1 | | -/** |
2 | | -* This is an example Angular + Ionic 3 service to wrap the Cordova audio player plugin. |
3 | | -* Simply drop this into your app, make sure you have the plugin installed, |
4 | | -* add the service to your app.module.ts and import it wherever you need. |
5 | | -* |
6 | | -* An example of such usage might be: |
7 | | -* |
8 | | -* constructor( |
9 | | -* private cdvAudioPlayer: CordovaAudioPlayerService, |
10 | | -* ) { |
11 | | -* this.cdvAudioPlayer.setOptions({ verbose: true, resetStreamOnPause: true }) |
12 | | -* .then(() => { |
13 | | -* this.cdvAudioPlayer.setPlaylistItems([ |
14 | | -* { trackId: '12345', assetUrl: testUrls[0], albumArt: testImgs[0], artist: 'Awesome', album: 'Test Files', title: 'Test 1' }, |
15 | | -* { trackId: '678900', assetUrl: testUrls[1], albumArt: testImgs[1], artist: 'Awesome', album: 'Test Files', title: 'Test 2' }, |
16 | | -* { trackId: 'a1b2c3d4', assetUrl: testUrls[2], albumArt: testImgs[2], artist: 'Awesome', album: 'Test Files', title: 'Test 3' }, |
17 | | -* { trackId: 'a1bSTREAM', assetUrl: testUrls[3], albumArt: testImgs[3], artist: 'Awesome', album: 'Streams', title: 'The Stream', isStream: true }, |
18 | | -* ]) |
19 | | -* .then(() => { |
20 | | -* this.cdvAudioPlayer.play(); |
21 | | -* }).catch((err) => console.log('YourService, cdvAudioPlayer setPlaylistItems error: ', err)); |
22 | | -* }).catch((err) => console.log('YourService, cdvAudioPlayer init error: ', err)); |
23 | | -* |
| 1 | +/** |
| 2 | +* This is an example Angular + Ionic 3 service to wrap the Cordova audio player plugin. |
| 3 | +* Simply drop this into your app, make sure you have the plugin installed, |
| 4 | +* add the service to your app.module.ts and import it wherever you need. |
| 5 | +* |
| 6 | +* An example of such usage might be: |
| 7 | +* |
| 8 | +* constructor( |
| 9 | +* private cdvAudioPlayer: CordovaAudioPlayerService, |
| 10 | +* ) { |
| 11 | +* this.cdvAudioPlayer.setOptions({ verbose: true, resetStreamOnPause: true }) |
| 12 | +* .then(() => { |
| 13 | +* this.cdvAudioPlayer.setPlaylistItems([ |
| 14 | +* { trackId: '12345', assetUrl: testUrls[0], albumArt: testImgs[0], artist: 'Awesome', album: 'Test Files', title: 'Test 1' }, |
| 15 | +* { trackId: '678900', assetUrl: testUrls[1], albumArt: testImgs[1], artist: 'Awesome', album: 'Test Files', title: 'Test 2' }, |
| 16 | +* { trackId: 'a1b2c3d4', assetUrl: testUrls[2], albumArt: testImgs[2], artist: 'Awesome', album: 'Test Files', title: 'Test 3' }, |
| 17 | +* { trackId: 'a1bSTREAM', assetUrl: testUrls[3], albumArt: testImgs[3], artist: 'Awesome', album: 'Streams', title: 'The Stream', isStream: true }, |
| 18 | +* ]) |
| 19 | +* .then(() => { |
| 20 | +* this.cdvAudioPlayer.play(); |
| 21 | +* }).catch((err) => console.log('YourService, cdvAudioPlayer setPlaylistItems error: ', err)); |
| 22 | +* }).catch((err) => console.log('YourService, cdvAudioPlayer init error: ', err)); |
| 23 | +* |
24 | 24 | * this.cdvAudioPlayer.setOptions({ verbose: true, resetStreamOnPause: true }); |
25 | 25 | * this.cdvAudioPlayer.setVolume(0.5); |
26 | 26 | * |
27 | | -* this.cdvAudioPlayer.onStatus.subscribe((status) => { |
28 | | -* console.log('YourService: Got RmxAudioPlayer onStatus: ', status); |
29 | | -* }); |
30 | | -* } |
| 27 | +* this.cdvAudioPlayer.onStatus.subscribe((status) => { |
| 28 | +* console.log('YourService: Got RmxAudioPlayer onStatus: ', status); |
| 29 | +* }); |
| 30 | +* } |
31 | 31 | */ |
32 | 32 | import { Injectable, NgZone } from '@angular/core'; |
33 | 33 | import { Platform } from 'ionic-angular'; |
@@ -250,12 +250,6 @@ export class CordovaAudioPlayerService { |
250 | 250 | }).catch((ex) => console.warn(ex)); |
251 | 251 | } |
252 | 252 |
|
253 | | - getTotalDuration = () => { |
254 | | - return this.wrapPromise('getTotalDuration', (resolve, reject) => { |
255 | | - this.AudioPlayer.getTotalDuration(this.getSuccessCb(resolve), this.getErrorCb(reject)); |
256 | | - }).catch((ex) => console.warn(ex)); |
257 | | - } |
258 | | - |
259 | 253 | getQueuePosition = () => { |
260 | 254 | return this.wrapPromise('getQueuePosition', (resolve, reject) => { |
261 | 255 | this.AudioPlayer.getQueuePosition(this.getSuccessCb(resolve), this.getErrorCb(reject)); |
@@ -285,10 +279,10 @@ export class CordovaAudioPlayerService { |
285 | 279 | this.Log.log(`AudioPlayerSuccessCb [${name}]:`, data); |
286 | 280 | return data; |
287 | 281 | }) |
288 | | - .catch((err) => { |
289 | | - this.Log.warn(`AudioPlayerSuccessCb [${name}]:`, err); |
290 | | - throw err; |
291 | | - }); |
| 282 | + .catch((err) => { |
| 283 | + this.Log.warn(`AudioPlayerSuccessCb [${name}]:`, err); |
| 284 | + throw err; |
| 285 | + }); |
292 | 286 | } |
293 | 287 |
|
294 | 288 | return executor; |
|
0 commit comments