Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(ionicnative): add instance wrapper #97

Merged
merged 17 commits into from
Apr 30, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,20 +34,23 @@ import {File} from './plugins/file';
import {Flashlight} from './plugins/flashlight';
import {Geolocation} from './plugins/geolocation';
import {Globalization} from './plugins/globalization';
import {GoogleMaps} from './plugins/googlemaps';
import {GoogleAnalytics} from './plugins/googleanalytics';
import {Hotspot} from './plugins/hotspot';
import {ImagePicker} from './plugins/imagepicker';
import {InAppBrowser} from './plugins/inappbrowser';
import {Keyboard} from './plugins/keyboard';
import {LaunchNavigator} from './plugins/launchnavigator';
import {LocalNotifications} from './plugins/localnotifications';
import {MediaPlugin} from './plugins/media';
import {Network, Connection} from './plugins/network';
import {Push} from './plugins/push';
import {Screenshot} from './plugins/screenshot';
import {SMS} from './plugins/sms';
import {SocialSharing} from './plugins/socialsharing';
import {SpinnerDialog} from './plugins/spinnerdialog';
import {Splashscreen} from './plugins/splashscreen';
import {SQLite} from './plugins/sqlite';
import {StatusBar} from './plugins/statusbar';
import {Toast} from './plugins/toast';
import {TouchID} from './plugins/touchid';
Expand Down Expand Up @@ -85,20 +88,23 @@ export {
Flashlight,
Geolocation,
Globalization,
GoogleMaps,
GoogleAnalytics,
Hotspot,
ImagePicker,
InAppBrowser,
Keyboard,
LaunchNavigator,
LocalNotifications,
MediaPlugin,
Network,
Push,
Screenshot,
SMS,
SocialSharing,
SpinnerDialog,
Splashscreen,
SQLite,
StatusBar,
Toast,
TouchID,
Expand Down Expand Up @@ -140,20 +146,23 @@ window['IonicNative'] = {
Flashlight: Flashlight,
Geolocation: Geolocation,
Globalization: Globalization,
GoogleMaps : GoogleMaps,
GoogleAnalytics: GoogleAnalytics,
Hotspot: Hotspot,
ImagePicker: ImagePicker,
InAppBrowser: InAppBrowser,
Keyboard: Keyboard,
LaunchNavigator: LaunchNavigator,
LocalNotifications: LocalNotifications,
MediaPlugin: MediaPlugin,
Network: Network,
Push: Push,
Screenshot: Screenshot,
SMS: SMS,
SocialSharing: SocialSharing,
SpinnerDialog: SpinnerDialog,
Splashscreen: Splashscreen,
SQLite: SQLite,
StatusBar: StatusBar,
Toast: Toast,
TouchID: TouchID,
Expand Down
37 changes: 37 additions & 0 deletions src/plugins/googlemaps.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import {Cordova, Plugin} from "./plugin";
import {Observable} from "rxjs/Observable";
import {CordovaInstance} from "./plugin";
/**
* Created by Ibrahim on 3/29/2016.
*/
declare var plugin : any;
/**
* @name Google Maps
*/
@Plugin({
pluginRef: 'plugin.google.maps',
plugin: 'cordova-plugin-googlemaps',
repo: 'https://github.com/mapsplugin/cordova-plugin-googlemaps'
})
export class GoogleMaps {

private _objectInstance : any;

constructor (elementId : string) {
this._objectInstance = plugin.google.maps.Map.getMap(document.getElementById(elementId));
}

@Cordova({
eventObservable: true,
event: 'plugin.google.maps.event.MAP_READY'
})
static onInit () : Observable<GoogleMaps> {return}

@CordovaInstance({
sync: true
})
setDebuggable (isDebuggable : boolean) : void {}

setClickable (isClickable : boolean) : void {}

}
168 changes: 168 additions & 0 deletions src/plugins/media.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,168 @@
import {CordovaInstance, Plugin} from './plugin';
declare var Media:any;
/**
* @name MediaPlugin
* @description
* @usage
* ```ts
* import {MediaPlugin} from 'ionic-native';
*
*
* ...
*
*
* // Playing a file
* var file = new MediaPlugin("path/to/file.mp3");
*
* // play the file
* file.play();
*
* // skip to 10 seconds
* file.seekTo(10000);
*
* // stop plying the file
* file.stop();
*
*
* ...
*
* // Recording to a file
* var newFile = new MediaPlugin("path/to/file.mp3");
* newFile.startRecord();
*
* newFile.stopRecord();
*
*
*
* ```
*/
@Plugin({
repo: 'https://github.com/apache/cordova-plugin-media',
plugin: 'cordova-plugin-media',
pluginRef: 'Media'
})
export class MediaPlugin {

// Constants
static MEDIA_NONE : number = 0;
static MEDIA_STARTING : number = 1;
static MEDIA_RUNNING : number = 2;
static MEDIA_PAUSED : number = 3;
static MEDIA_STOPPED : number = 4;

// Properties
private _objectInstance : any;

// Methods
/**
* Open a media file
* @param src {string} A URI containing the audio content.
*/
constructor (src : string) {
// TODO handle success, error, and status
this._objectInstance = new Media(src);
}

/**
* Returns the current amplitude of the current recording.
*/
@CordovaInstance()
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}

/**
* Returns the duration of an audio file in seconds. If the duration is unknown, it returns a value of -1.
*/
@CordovaInstance({
sync: true
})
getDuration () : number {return}

/**
* Starts or resumes playing an audio file.
*/
@CordovaInstance({
sync: true
})
play (iosOptions? : {
numberOfLoops? : number,
playAudioWhenScreenIsLocked? : boolean
}) : void {}

/**
* Pauses playing an audio file.
*/
@CordovaInstance({
sync: true
})
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.
*/
@CordovaInstance({
sync: true
})
release () : void {}

/**
* Sets the current position within an audio file.
* @param milliseconds
*/
@CordovaInstance({
sync: true
})
seekTo (milliseconds : 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.
*/
@CordovaInstance({
sync: true
})
setVolume (volume : number) : void {}

/**
* Starts recording an audio file.
*/
@CordovaInstance({
sync: true
})
startRecord () : void {}


/**
* Stops recording
*/
@CordovaInstance({
sync: true
})
stopRecord () : void {}


/**
* Stops playing an audio file.
*/
@CordovaInstance({
sync: true
})
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;}
code : number;
message : string;
}
Loading