Skip to content

fix: ts issues during build #23

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

Merged
merged 1 commit into from
Oct 15, 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
17 changes: 9 additions & 8 deletions demo/app/main-view-model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down Expand Up @@ -61,11 +62,11 @@ export class AudioDemo extends Observable {
metering: true,

infoCallback: () => {
console.log();

},

errorCallback: () => {
console.log();

// snackbar.simple('Error recording.');
}
};
Expand All @@ -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.");
}
}

Expand Down Expand Up @@ -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);
Expand All @@ -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');
}
};

Expand Down Expand Up @@ -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);
}
};
Expand Down
6 changes: 3 additions & 3 deletions demo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@
"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",
"babel-types": "6.11.1",
"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"
}
}
}
11 changes: 4 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,16 @@
"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": {
"build": "tsc",
"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",
Expand Down Expand Up @@ -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"
}
}
2 changes: 1 addition & 1 deletion src/ios/player.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down
12 changes: 9 additions & 3 deletions src/ios/recorder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand All @@ -29,8 +29,14 @@ export class TNSRecorder extends NSObject implements TNSRecordI {
this._recordingSession.requestRecordPermission((allowed: boolean) => {
if (allowed) {

var recordSetting = new NSMutableDictionary((<any>[NSNumber.numberWithInt(kAudioFormatMPEG4AAC), NSNumber.numberWithInt((<any>AVAudioQuality).Medium.rawValue), NSNumber.numberWithFloat(16000.0), NSNumber.numberWithInt(1)]),
(<any>["AVFormatIDKey", "AVEncoderAudioQualityKey", "AVSampleRateKey", "AVNumberOfChannelsKey"]));
// var recordSetting = new NSMutableDictionary((<any>[NSNumber.numberWithInt(kAudioFormatMPEG4AAC), NSNumber.numberWithInt((<any>AVAudioQuality).Medium.rawValue), NSNumber.numberWithFloat(16000.0), NSNumber.numberWithInt(1)]),
// (<any>["AVFormatIDKey", "AVEncoderAudioQualityKey", "AVSampleRateKey", "AVNumberOfChannelsKey"]));

let recordSetting = NSMutableDictionary.alloc().init();
recordSetting.setValueForKey(NSNumber.numberWithInt(kAudioFormatMPEG4AAC), 'AVFormatIDKey');
recordSetting.setValueForKey(NSNumber.numberWithInt((<any>AVAudioQuality).Medium.rawValue), 'AVEncoderAudioQualityKey');
recordSetting.setValueForKey(NSNumber.numberWithFloat(16000.0), 'AVSampleRateKey');
recordSetting.setValueForKey(NSNumber.numberWithInt(1), 'AVNumberOfChannelsKey');

errorRef = new interop.Reference();

Expand Down
11 changes: 7 additions & 4 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
],
Expand Down