parent
a250bd3e81
commit
5df447a02f
@ -1,4 +1,5 @@
|
|||||||
import {CordovaInstance, Plugin} from './plugin';
|
import {CordovaInstance, Plugin} from './plugin';
|
||||||
|
import {Observable} from 'rxjs/Rx';
|
||||||
declare var Media: any;
|
declare var Media: any;
|
||||||
/**
|
/**
|
||||||
* @name MediaPlugin
|
* @name MediaPlugin
|
||||||
@ -14,6 +15,13 @@ declare var Media: any;
|
|||||||
* // Playing a file
|
* // Playing a file
|
||||||
* var file = new MediaPlugin("path/to/file.mp3");
|
* var file = new MediaPlugin("path/to/file.mp3");
|
||||||
*
|
*
|
||||||
|
* // Catch the Success & Error Output
|
||||||
|
* file.init.then(() => {
|
||||||
|
* console.log("Playback Finished");
|
||||||
|
* }, (err) => {
|
||||||
|
* console.log("somthing went wrong! error code: "+err.code+" message: "+err.message);
|
||||||
|
* });
|
||||||
|
*
|
||||||
* // play the file
|
* // play the file
|
||||||
* file.play();
|
* file.play();
|
||||||
*
|
*
|
||||||
@ -52,6 +60,8 @@ export class MediaPlugin {
|
|||||||
|
|
||||||
// Properties
|
// Properties
|
||||||
private _objectInstance: any;
|
private _objectInstance: any;
|
||||||
|
status: Observable<any>;
|
||||||
|
init: Promise<any>;
|
||||||
|
|
||||||
// Methods
|
// Methods
|
||||||
/**
|
/**
|
||||||
@ -59,8 +69,10 @@ export class MediaPlugin {
|
|||||||
* @param src {string} A URI containing the audio content.
|
* @param src {string} A URI containing the audio content.
|
||||||
*/
|
*/
|
||||||
constructor (src: string) {
|
constructor (src: string) {
|
||||||
// TODO handle success, error, and status
|
let res, rej, next;
|
||||||
this._objectInstance = new Media(src);
|
this.init = new Promise<any>((resolve, reject) => {res = resolve; rej = reject;});
|
||||||
|
this.status = new Observable((observer) => {next = observer.next;});
|
||||||
|
this._objectInstance = new Media(src, res, rej, next);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user