mirror of
https://github.com/danielsogl/awesome-cordova-plugins.git
synced 2025-02-01 02:53:03 +08:00
refactor(media):
This commit is contained in:
parent
6791754874
commit
df1d42fa99
@ -1,6 +1,9 @@
|
||||
import {CordovaInstance, Plugin} from './plugin';
|
||||
import {Observable} from 'rxjs/Observable';
|
||||
import { CordovaInstance, Plugin } from './plugin';
|
||||
import { Observable } from 'rxjs/Observable';
|
||||
|
||||
|
||||
declare var Media: any;
|
||||
|
||||
/**
|
||||
* @name MediaPlugin
|
||||
* @description
|
||||
@ -85,11 +88,11 @@ export class MediaPlugin {
|
||||
* Open a media file
|
||||
* @param src {string} A URI containing the audio content.
|
||||
*/
|
||||
constructor (src: string) {
|
||||
constructor(src: string) {
|
||||
let res, rej, next;
|
||||
this.init = new Promise<any>((resolve, reject) => {res = resolve; rej = reject; });
|
||||
this.init = new Promise<any>((resolve, reject) => { res = resolve; rej = reject; });
|
||||
this.status = new Observable((observer) => {
|
||||
next = data => observer.next(data);
|
||||
next = data => observer.next(data);
|
||||
});
|
||||
this._objectInstance = new Media(src, res, rej, next);
|
||||
}
|
||||
@ -98,13 +101,13 @@ export class MediaPlugin {
|
||||
* Returns the current amplitude of the current recording.
|
||||
*/
|
||||
@CordovaInstance()
|
||||
getCurrentAmplitude (): Promise<any> {return; }
|
||||
getCurrentAmplitude(): Promise<any> { return; }
|
||||
|
||||
/**
|
||||
* Returns the current position within an audio file. Also updates the Media object's position parameter.
|
||||
*/
|
||||
@CordovaInstance()
|
||||
getCurrentPosition (): Promise<any> {return; }
|
||||
getCurrentPosition(): Promise<any> { return; }
|
||||
|
||||
/**
|
||||
* Returns the duration of an audio file in seconds. If the duration is unknown, it returns a value of -1.
|
||||
@ -112,7 +115,7 @@ export class MediaPlugin {
|
||||
@CordovaInstance({
|
||||
sync: true
|
||||
})
|
||||
getDuration (): number {return; }
|
||||
getDuration(): number { return; }
|
||||
|
||||
/**
|
||||
* Starts or resumes playing an audio file.
|
||||
@ -120,10 +123,10 @@ export class MediaPlugin {
|
||||
@CordovaInstance({
|
||||
sync: true
|
||||
})
|
||||
play (iosOptions?: {
|
||||
play(iosOptions?: {
|
||||
numberOfLoops?: number,
|
||||
playAudioWhenScreenIsLocked?: boolean
|
||||
}): void {}
|
||||
}): void { }
|
||||
|
||||
/**
|
||||
* Pauses playing an audio file.
|
||||
@ -131,7 +134,7 @@ export class MediaPlugin {
|
||||
@CordovaInstance({
|
||||
sync: true
|
||||
})
|
||||
pause (): void {}
|
||||
pause(): void { }
|
||||
|
||||
/**
|
||||
* Releases the underlying operating system's audio resources. This is particularly important for Android, since there are a finite amount of OpenCore instances for media playback. Applications should call the release function for any Media resource that is no longer needed.
|
||||
@ -139,7 +142,7 @@ export class MediaPlugin {
|
||||
@CordovaInstance({
|
||||
sync: true
|
||||
})
|
||||
release (): void {}
|
||||
release(): void { }
|
||||
|
||||
/**
|
||||
* Sets the current position within an audio file.
|
||||
@ -148,7 +151,7 @@ export class MediaPlugin {
|
||||
@CordovaInstance({
|
||||
sync: true
|
||||
})
|
||||
seekTo (milliseconds: number): void {}
|
||||
seekTo(milliseconds: number): void { }
|
||||
|
||||
/**
|
||||
* Set the volume for an audio file.
|
||||
@ -157,7 +160,7 @@ export class MediaPlugin {
|
||||
@CordovaInstance({
|
||||
sync: true
|
||||
})
|
||||
setVolume (volume: number): void {}
|
||||
setVolume(volume: number): void { }
|
||||
|
||||
/**
|
||||
* Starts recording an audio file.
|
||||
@ -165,7 +168,7 @@ export class MediaPlugin {
|
||||
@CordovaInstance({
|
||||
sync: true
|
||||
})
|
||||
startRecord (): void {}
|
||||
startRecord(): void { }
|
||||
|
||||
|
||||
/**
|
||||
@ -174,7 +177,7 @@ export class MediaPlugin {
|
||||
@CordovaInstance({
|
||||
sync: true
|
||||
})
|
||||
stopRecord (): void {}
|
||||
stopRecord(): void { }
|
||||
|
||||
|
||||
/**
|
||||
@ -183,17 +186,15 @@ export class MediaPlugin {
|
||||
@CordovaInstance({
|
||||
sync: true
|
||||
})
|
||||
stop (): void {}
|
||||
|
||||
|
||||
stop(): void { }
|
||||
|
||||
}
|
||||
|
||||
export class MediaError {
|
||||
static get MEDIA_ERR_ABORTED () {return 1; }
|
||||
static get MEDIA_ERR_NETWORK () {return 2; }
|
||||
static get MEDIA_ERR_DECODE () {return 3; }
|
||||
static get MEDIA_ERR_NONE_SUPPORTED () {return 4; }
|
||||
static get MEDIA_ERR_ABORTED() { return 1; }
|
||||
static get MEDIA_ERR_NETWORK() { return 2; }
|
||||
static get MEDIA_ERR_DECODE() { return 3; }
|
||||
static get MEDIA_ERR_NONE_SUPPORTED() { return 4; }
|
||||
code: number;
|
||||
message: string;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user