diff --git a/demo/app/main-view-model.ts b/demo/app/main-view-model.ts index 60549d5..8e761fb 100644 --- a/demo/app/main-view-model.ts +++ b/demo/app/main-view-model.ts @@ -3,6 +3,7 @@ import * as fs from 'file-system'; import * as app from 'application'; import * as color from 'color'; import * as platform from 'platform'; +import * as dialogs from 'ui/dialogs'; import { SnackBar } from 'nativescript-snackbar'; import {TNSRecorder, TNSPlayer, AudioPlayerOptions, AudioRecorderOptions} from 'nativescript-audio'; @@ -61,11 +62,11 @@ export class AudioDemo extends Observable { metering: true, infoCallback: () => { - console.log(); + }, errorCallback: () => { - console.log(); + // snackbar.simple('Error recording.'); } }; @@ -79,10 +80,10 @@ export class AudioDemo extends Observable { }, (err) => { this.set("isRecording", false); this.resetMeter(); - alert(err); + dialogs.alert(err); }); } else { - alert("This device cannot record audio."); + dialogs.alert("This device cannot record audio."); } } @@ -134,7 +135,7 @@ export class AudioDemo extends Observable { var playerOptions: AudioPlayerOptions = { audioFile: `~/audio/recording.${this.platformExtension()}`, - loop: true, + loop: false, completeCallback: () => { this._SnackBar.simple("Audio file complete"); this.set("isPlaying", false); @@ -149,12 +150,12 @@ export class AudioDemo extends Observable { }, errorCallback: () => { - alert('Error callback'); + dialogs.alert('Error callback'); this.set("isPlaying", false); }, infoCallback: () => { - alert('Info callback'); + dialogs.alert('Info callback'); } }; @@ -196,7 +197,7 @@ export class AudioDemo extends Observable { }, infoCallback: (info) => { - alert('Info callback: ' + info.msg); + dialogs.alert('Info callback: ' + info.msg); console.log("what: " + info); } }; diff --git a/demo/package.json b/demo/package.json index 37df012..b74e538 100644 --- a/demo/package.json +++ b/demo/package.json @@ -13,7 +13,7 @@ "nativescript-snackbar": "^1.0.3", "nativescript-statusbar": "^1.0.0", "nativescript-theme-core": "^0.1.2", - "tns-core-modules": "next" + "tns-core-modules": "^2.3.0" }, "devDependencies": { "babel-traverse": "6.12.0", @@ -21,7 +21,7 @@ "babylon": "6.8.4", "lazy": "1.0.11", "nativescript-dev-typescript": "^0.3.2", - "tns-platform-declarations": "^2.0.0", + "tns-platform-declarations": "^2.3.0", "typescript": "^1.8.10" } -} +} \ No newline at end of file diff --git a/package.json b/package.json index cb04db6..eccacae 100644 --- a/package.json +++ b/package.json @@ -6,11 +6,8 @@ "typings": "index.d.ts", "nativescript": { "platforms": { - "android": "2.2.0", - "ios": "2.2.1" - }, - "tns-ios": { - "version": "2.3.0" + "android": "2.3.0", + "ios": "2.3.0" } }, "scripts": { @@ -18,7 +15,7 @@ "demo.ios": "npm run preparedemo; cd demo; tns emulate ios", "demo.android": "npm run preparedemo; cd demo; tns emulate android", "preparedemo": "npm run build; cd demo; tns plugin remove nativescript-audio; tns plugin add ..; tns install", - "setup": "cd demo; npm install; cd ..; npm run build; cd demo; tns plugin add ..; cd .." + "setup": "cd demo; npm i; cd ..; npm i; npm run build; cd demo; tns plugin add ..; cd .." }, "repository": { "type": "git", @@ -58,7 +55,7 @@ "homepage": "https://github.com/bradmartin/nativescript-audio", "readmeFilename": "README.md", "devDependencies": { - "tns-platform-declarations": "^2.0.0", + "tns-platform-declarations": "^2.3.0", "typescript": "^1.8.10" } } \ No newline at end of file diff --git a/src/ios/player.ts b/src/ios/player.ts index 17f4a28..e50addc 100644 --- a/src/ios/player.ts +++ b/src/ios/player.ts @@ -4,7 +4,7 @@ import {knownFolders, path} from 'file-system'; import {TNSPlayerI} from '../common'; import {AudioPlayerOptions} from '../options'; -declare var NSURLSession, AVAudioPlayer, NSURL, AVAudioPlayerDelegate, NSObject: any; +declare var NSURLSession, AVAudioPlayer, NSURL, AVAudioPlayerDelegate; export class TNSPlayer extends NSObject implements TNSPlayerI { public static ObjCProtocols = [AVAudioPlayerDelegate]; diff --git a/src/ios/recorder.ts b/src/ios/recorder.ts index 6b141ed..c29feff 100644 --- a/src/ios/recorder.ts +++ b/src/ios/recorder.ts @@ -4,7 +4,7 @@ import {knownFolders, path} from 'file-system'; import {TNSRecordI} from '../common'; import {AudioRecorderOptions} from '../options'; -declare var interop; +declare var interop, kAudioFormatMPEG4AAC, AVAudioQuality; export class TNSRecorder extends NSObject implements TNSRecordI { public static ObjCProtocols = [AVAudioRecorderDelegate]; @@ -29,8 +29,14 @@ export class TNSRecorder extends NSObject implements TNSRecordI { this._recordingSession.requestRecordPermission((allowed: boolean) => { if (allowed) { - var recordSetting = new NSMutableDictionary(([NSNumber.numberWithInt(kAudioFormatMPEG4AAC), NSNumber.numberWithInt((AVAudioQuality).Medium.rawValue), NSNumber.numberWithFloat(16000.0), NSNumber.numberWithInt(1)]), - (["AVFormatIDKey", "AVEncoderAudioQualityKey", "AVSampleRateKey", "AVNumberOfChannelsKey"])); + // var recordSetting = new NSMutableDictionary(([NSNumber.numberWithInt(kAudioFormatMPEG4AAC), NSNumber.numberWithInt((AVAudioQuality).Medium.rawValue), NSNumber.numberWithFloat(16000.0), NSNumber.numberWithInt(1)]), + // (["AVFormatIDKey", "AVEncoderAudioQualityKey", "AVSampleRateKey", "AVNumberOfChannelsKey"])); + + let recordSetting = NSMutableDictionary.alloc().init(); + recordSetting.setValueForKey(NSNumber.numberWithInt(kAudioFormatMPEG4AAC), 'AVFormatIDKey'); + recordSetting.setValueForKey(NSNumber.numberWithInt((AVAudioQuality).Medium.rawValue), 'AVEncoderAudioQualityKey'); + recordSetting.setValueForKey(NSNumber.numberWithFloat(16000.0), 'AVSampleRateKey'); + recordSetting.setValueForKey(NSNumber.numberWithInt(1), 'AVNumberOfChannelsKey'); errorRef = new interop.Reference(); diff --git a/tsconfig.json b/tsconfig.json index 5b23775..ca7fe2d 100755 --- a/tsconfig.json +++ b/tsconfig.json @@ -8,13 +8,16 @@ "declaration": true, "noEmitOnError": false, "noEmitHelpers": true, - "noImplicitUseStrict": true + "noImplicitUseStrict": true, + "noLib": true }, "files": [ + "manual_typings/base.d.ts", + "node_modules/typescript/lib/lib.core.d.ts", + "node_modules/tns-platform-declarations/tns-core-modules/android17.d.ts", + "node_modules/tns-platform-declarations/tns-core-modules/ios/ios.d.ts", + "node_modules/tns-platform-declarations/tns-core-modules/org.nativescript.widgets.d.ts", "demo/node_modules/tns-core-modules/tns-core-modules.d.ts", - "node_modules/tns-platform-declarations/android17.d.ts", - "node_modules/tns-platform-declarations/ios.d.ts", - "node_modules/tns-platform-declarations/org.nativescript.widgets.d.ts", "audio.android.ts", "audio.ios.ts" ],