You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by an...@apache.org on 2017/01/20 08:44:45 UTC
cordova-plugin-media git commit: CB-12369: Add plugin typings from
DefinitelyTyped
Repository: cordova-plugin-media
Updated Branches:
refs/heads/master 3357a6347 -> bc16dfd7c
CB-12369: Add plugin typings from DefinitelyTyped
This closes #126
Project: http://git-wip-us.apache.org/repos/asf/cordova-plugin-media/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugin-media/commit/bc16dfd7
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-media/tree/bc16dfd7
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-media/diff/bc16dfd7
Branch: refs/heads/master
Commit: bc16dfd7cfbe4c62d06966167d006874468671bc
Parents: 3357a63
Author: Nikita Matrosov <v-...@microsoft.com>
Authored: Thu Jan 19 16:09:39 2017 +0300
Committer: Vladimir Kotikov <ko...@gmail.com>
Committed: Fri Jan 20 11:44:24 2017 +0300
----------------------------------------------------------------------
package.json | 1 +
types/index.d.ts | 84 +++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 85 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-plugin-media/blob/bc16dfd7/package.json
----------------------------------------------------------------------
diff --git a/package.json b/package.json
index bedb79b..52da0fe 100644
--- a/package.json
+++ b/package.json
@@ -2,6 +2,7 @@
"name": "cordova-plugin-media",
"version": "2.4.2-dev",
"description": "Cordova Media Plugin",
+ "types": "./types/index.d.ts",
"cordova": {
"id": "cordova-plugin-media",
"platforms": [
http://git-wip-us.apache.org/repos/asf/cordova-plugin-media/blob/bc16dfd7/types/index.d.ts
----------------------------------------------------------------------
diff --git a/types/index.d.ts b/types/index.d.ts
new file mode 100644
index 0000000..3e47fb9
--- /dev/null
+++ b/types/index.d.ts
@@ -0,0 +1,84 @@
+// Type definitions for Apache Cordova Media plugin
+// Project: https://github.com/apache/cordova-plugin-media
+// Definitions by: Microsoft Open Technologies Inc <http://msopentech.com>
+// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
+//
+// Copyright (c) Microsoft Open Technologies Inc
+// Licensed under the MIT license
+
+declare var Media: {
+ new (
+ src: string,
+ mediaSuccess: () => void,
+ mediaError?: (error: MediaError) => any,
+ mediaStatus?: (status: number) => void): Media;
+ //Media statuses
+ MEDIA_NONE: number;
+ MEDIA_STARTING: number;
+ MEDIA_RUNNING: number;
+ MEDIA_PAUSED: number;
+ MEDIA_STOPPED: number
+};
+
+/**
+ * This plugin provides the ability to record and play back audio files on a device.
+ * NOTE: The current implementation does not adhere to a W3C specification for media capture,
+ * and is provided for convenience only. A future implementation will adhere to the latest
+ * W3C specification and may deprecate the current APIs.
+ */
+interface Media {
+ /**
+ * Returns the current position within an audio file. Also updates the Media object's position parameter.
+ * @param mediaSuccess The callback that is passed the current position in seconds.
+ * @param mediaError The callback to execute if an error occurs.
+ */
+ getCurrentPosition(
+ mediaSuccess: (position: number) => void,
+ mediaError?: (error: MediaError) => void): void;
+ /** Returns the duration of an audio file in seconds. If the duration is unknown, it returns a value of -1. */
+ getDuration(): number;
+ /**
+ * Starts or resumes playing an audio file.
+ * @param iosPlayOptions: iOS options quirks
+ */
+ play(iosPlayOptions?: IosPlayOptions): void;
+ /** Pauses playing an audio file. */
+ 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.
+ */
+ release(): void;
+ /**
+ * Sets the current position within an audio file.
+ * @param position Position in milliseconds.
+ */
+ seekTo(position: number): void;
+ /**
+ * Set the volume for an audio file.
+ * @param volume The volume to set for playback. The value must be within the range of 0.0 to 1.0.
+ */
+ setVolume(volume: number): void;
+ /** Starts recording an audio file. */
+ startRecord(): void;
+ /** Stops recording an audio file. */
+ stopRecord(): void;
+ /** Stops playing an audio file. */
+ stop(): void;
+ /**
+ * The position within the audio playback, in seconds.
+ * Not automatically updated during play; call getCurrentPosition to update.
+ */
+ position: number;
+ /** The duration of the media, in seconds. */
+ duration: number;
+}
+/**
+ * iOS optional parameters for media.play
+ * See https://github.com/apache/cordova-plugin-media#ios-quirks
+ */
+interface IosPlayOptions {
+ numberOfLoops?: number;
+ playAudioWhenScreenIsLocked?: boolean;
+}
\ No newline at end of file
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org