nativescript-audio
Advanced tools
Comparing version 4.3.4 to 4.3.5
@@ -16,4 +16,4 @@ "use strict"; | ||
case android.media.AudioManager.AUDIOFOCUS_GAIN: | ||
common_1.TNS_Player_Log("AUDIOFOCUS_GAIN"); | ||
common_1.TNS_Player_Log("this._lastPlayerVolume", _this._lastPlayerVolume); | ||
common_1.TNS_Player_Log('AUDIOFOCUS_GAIN'); | ||
common_1.TNS_Player_Log('this._lastPlayerVolume', _this._lastPlayerVolume); | ||
if (_this._lastPlayerVolume && _this._lastPlayerVolume >= 10) { | ||
@@ -23,3 +23,3 @@ _this.volume = 1.0; | ||
else if (_this._lastPlayerVolume) { | ||
_this.volume = parseFloat("0." + _this._lastPlayerVolume.toString()); | ||
_this.volume = parseFloat('0.' + _this._lastPlayerVolume.toString()); | ||
} | ||
@@ -29,16 +29,16 @@ _this.resume(); | ||
case android.media.AudioManager.AUDIOFOCUS_GAIN_TRANSIENT: | ||
common_1.TNS_Player_Log("AUDIOFOCUS_GAIN_TRANSIENT"); | ||
common_1.TNS_Player_Log('AUDIOFOCUS_GAIN_TRANSIENT'); | ||
break; | ||
case android.media.AudioManager.AUDIOFOCUS_LOSS: | ||
common_1.TNS_Player_Log("AUDIOFOCUS_LOSS"); | ||
common_1.TNS_Player_Log('AUDIOFOCUS_LOSS'); | ||
_this.pause(); | ||
break; | ||
case android.media.AudioManager.AUDIOFOCUS_LOSS_TRANSIENT: | ||
common_1.TNS_Player_Log("AUDIOFOCUS_LOSS_TRANSIENT"); | ||
common_1.TNS_Player_Log('AUDIOFOCUS_LOSS_TRANSIENT'); | ||
_this.pause(); | ||
break; | ||
case android.media.AudioManager.AUDIOFOCUS_LOSS_TRANSIENT_CAN_DUCK: | ||
common_1.TNS_Player_Log("AUDIOFOCUS_LOSS_TRANSIENT_CAN_DUCK"); | ||
common_1.TNS_Player_Log('AUDIOFOCUS_LOSS_TRANSIENT_CAN_DUCK'); | ||
_this._lastPlayerVolume = _this.volume; | ||
common_1.TNS_Player_Log("this._lastPlayerVolume", _this._lastPlayerVolume); | ||
common_1.TNS_Player_Log('this._lastPlayerVolume', _this._lastPlayerVolume); | ||
_this.volume = 0.2; | ||
@@ -50,3 +50,3 @@ break; | ||
this._mAudioFocusGranted = this._requestAudioFocus(); | ||
common_1.TNS_Player_Log("_mAudioFocusGranted", this._mAudioFocusGranted); | ||
common_1.TNS_Player_Log('_mAudioFocusGranted', this._mAudioFocusGranted); | ||
} | ||
@@ -79,3 +79,4 @@ Object.defineProperty(TNSPlayer.prototype, "events", { | ||
get: function () { | ||
var mgr = app.android.context.getSystemService(android.content.Context.AUDIO_SERVICE); | ||
var ctx = this._getAndroidContext(); | ||
var mgr = ctx.getSystemService(android.content.Context.AUDIO_SERVICE); | ||
return mgr.getStreamVolume(android.media.AudioManager.STREAM_MUSIC); | ||
@@ -125,20 +126,20 @@ }, | ||
var audioPath = common_1.resolveAudioFilePath(options.audioFile); | ||
common_1.TNS_Player_Log("audioPath", audioPath); | ||
common_1.TNS_Player_Log('audioPath', audioPath); | ||
if (!_this._player) { | ||
common_1.TNS_Player_Log("android mediaPlayer is not initialized, creating new instance"); | ||
common_1.TNS_Player_Log('android mediaPlayer is not initialized, creating new instance'); | ||
_this._player = new android.media.MediaPlayer(); | ||
} | ||
_this._mAudioFocusGranted = _this._requestAudioFocus(); | ||
common_1.TNS_Player_Log("_mAudioFocusGranted", _this._mAudioFocusGranted); | ||
common_1.TNS_Player_Log('_mAudioFocusGranted', _this._mAudioFocusGranted); | ||
_this._player.setAudioStreamType(android.media.AudioManager.STREAM_MUSIC); | ||
common_1.TNS_Player_Log("resetting mediaPlayer..."); | ||
common_1.TNS_Player_Log('resetting mediaPlayer...'); | ||
_this._player.reset(); | ||
common_1.TNS_Player_Log("setting datasource", audioPath); | ||
common_1.TNS_Player_Log('setting datasource', audioPath); | ||
_this._player.setDataSource(audioPath); | ||
if (utils_1.isFileOrResourcePath(audioPath)) { | ||
common_1.TNS_Player_Log("preparing mediaPlayer..."); | ||
common_1.TNS_Player_Log('preparing mediaPlayer...'); | ||
_this._player.prepare(); | ||
} | ||
else { | ||
common_1.TNS_Player_Log("preparing mediaPlayer async..."); | ||
common_1.TNS_Player_Log('preparing mediaPlayer async...'); | ||
_this._player.prepareAsync(); | ||
@@ -161,3 +162,3 @@ } | ||
_this._player.reset(); | ||
common_1.TNS_Player_Log("errorCallback", error); | ||
common_1.TNS_Player_Log('errorCallback', error); | ||
options.errorCallback({ player: player, error: error, extra: extra }); | ||
@@ -171,3 +172,3 @@ return true; | ||
onInfo: function (player, info, extra) { | ||
common_1.TNS_Player_Log("infoCallback", info); | ||
common_1.TNS_Player_Log('infoCallback', info); | ||
options.infoCallback({ player: player, info: info, extra: extra }); | ||
@@ -181,3 +182,3 @@ return true; | ||
if (options.autoPlay) { | ||
common_1.TNS_Player_Log("options.autoPlay", options.autoPlay); | ||
common_1.TNS_Player_Log('options.autoPlay', options.autoPlay); | ||
_this.play(); | ||
@@ -190,3 +191,3 @@ } | ||
catch (ex) { | ||
common_1.TNS_Player_Log("playFromFile error", ex); | ||
common_1.TNS_Player_Log('playFromFile error', ex); | ||
reject(ex); | ||
@@ -214,3 +215,3 @@ } | ||
if (_this._player && _this._player.isPlaying()) { | ||
common_1.TNS_Player_Log("pausing player"); | ||
common_1.TNS_Player_Log('pausing player'); | ||
_this._player.pause(); | ||
@@ -222,3 +223,3 @@ _this._sendEvent(options_1.AudioPlayerEvents.paused); | ||
catch (ex) { | ||
common_1.TNS_Player_Log("pause error", ex); | ||
common_1.TNS_Player_Log('pause error', ex); | ||
reject(ex); | ||
@@ -236,4 +237,4 @@ } | ||
app.android.registerBroadcastReceiver(android.media.AudioManager.ACTION_AUDIO_BECOMING_NOISY, function (context, intent) { | ||
common_1.TNS_Player_Log("ACTION_AUDIO_BECOMING_NOISY onReceiveCallback"); | ||
common_1.TNS_Player_Log("intent", intent); | ||
common_1.TNS_Player_Log('ACTION_AUDIO_BECOMING_NOISY onReceiveCallback'); | ||
common_1.TNS_Player_Log('intent', intent); | ||
_this.pause(); | ||
@@ -246,3 +247,3 @@ }); | ||
catch (ex) { | ||
common_1.TNS_Player_Log("Error trying to play audio.", ex); | ||
common_1.TNS_Player_Log('Error trying to play audio.', ex); | ||
reject(ex); | ||
@@ -254,3 +255,3 @@ } | ||
if (this._player) { | ||
common_1.TNS_Player_Log("resume"); | ||
common_1.TNS_Player_Log('resume'); | ||
this._player.start(); | ||
@@ -265,3 +266,3 @@ this._sendEvent(options_1.AudioPlayerEvents.started); | ||
if (_this._player) { | ||
common_1.TNS_Player_Log("seekTo", time); | ||
common_1.TNS_Player_Log('seekTo', time); | ||
_this._player.seekTo(time); | ||
@@ -273,3 +274,3 @@ _this._sendEvent(options_1.AudioPlayerEvents.seek); | ||
catch (ex) { | ||
common_1.TNS_Player_Log("seekTo error", ex); | ||
common_1.TNS_Player_Log('seekTo error', ex); | ||
reject(ex); | ||
@@ -281,3 +282,3 @@ } | ||
if (android.os.Build.VERSION.SDK_INT >= 23 && this.play) { | ||
common_1.TNS_Player_Log("setting the mediaPlayer playback speed", speed); | ||
common_1.TNS_Player_Log('setting the mediaPlayer playback speed', speed); | ||
if (this._player.isPlaying()) { | ||
@@ -292,3 +293,3 @@ this._player.setPlaybackParams(this._player.getPlaybackParams().setSpeed(speed)); | ||
else { | ||
common_1.TNS_Player_Log("Android device API is not 23+. Cannot set the playbackRate on lower Android APIs."); | ||
common_1.TNS_Player_Log('Android device API is not 23+. Cannot set the playbackRate on lower Android APIs.'); | ||
} | ||
@@ -301,8 +302,8 @@ }; | ||
if (_this._player) { | ||
common_1.TNS_Player_Log("disposing of mediaPlayer instance", _this._player); | ||
common_1.TNS_Player_Log('disposing of mediaPlayer instance', _this._player); | ||
_this._player.stop(); | ||
_this._player.reset(); | ||
common_1.TNS_Player_Log("unregisterBroadcastReceiver ACTION_AUDIO_BECOMING_NOISY..."); | ||
common_1.TNS_Player_Log('unregisterBroadcastReceiver ACTION_AUDIO_BECOMING_NOISY...'); | ||
app.android.unregisterBroadcastReceiver(android.media.AudioManager.ACTION_AUDIO_BECOMING_NOISY); | ||
common_1.TNS_Player_Log("abandoning audio focus..."); | ||
common_1.TNS_Player_Log('abandoning audio focus...'); | ||
_this._abandonAudioFocus(); | ||
@@ -313,3 +314,3 @@ } | ||
catch (ex) { | ||
common_1.TNS_Player_Log("dispose error", ex); | ||
common_1.TNS_Player_Log('dispose error', ex); | ||
reject(ex); | ||
@@ -332,7 +333,7 @@ } | ||
var duration = _this._player ? _this._player.getDuration() : 0; | ||
common_1.TNS_Player_Log("audio track duration", duration); | ||
common_1.TNS_Player_Log('audio track duration', duration); | ||
resolve(duration.toString()); | ||
} | ||
catch (ex) { | ||
common_1.TNS_Player_Log("getAudioTrackDuration error", ex); | ||
common_1.TNS_Player_Log('getAudioTrackDuration error', ex); | ||
reject(ex); | ||
@@ -354,3 +355,4 @@ } | ||
if (!this._mAudioFocusGranted) { | ||
var am = app.android.context.getSystemService(android.content.Context.AUDIO_SERVICE); | ||
var ctx = this._getAndroidContext(); | ||
var am = ctx.getSystemService(android.content.Context.AUDIO_SERVICE); | ||
var focusResult = am.requestAudioFocus(this._mOnAudioFocusChangeListener, android.media.AudioManager.STREAM_MUSIC, android.media.AudioManager.AUDIOFOCUS_GAIN); | ||
@@ -361,3 +363,3 @@ if (focusResult === android.media.AudioManager.AUDIOFOCUS_REQUEST_GRANTED) { | ||
else { | ||
common_1.TNS_Player_Log("Failed to get audio focus."); | ||
common_1.TNS_Player_Log('Failed to get audio focus.'); | ||
result = false; | ||
@@ -369,3 +371,4 @@ } | ||
TNSPlayer.prototype._abandonAudioFocus = function () { | ||
var am = app.android.context.getSystemService(android.content.Context.AUDIO_SERVICE); | ||
var ctx = this._getAndroidContext(); | ||
var am = ctx.getSystemService(android.content.Context.AUDIO_SERVICE); | ||
var result = am.abandonAudioFocus(this._mOnAudioFocusChangeListener); | ||
@@ -376,6 +379,19 @@ if (result === android.media.AudioManager.AUDIOFOCUS_REQUEST_GRANTED) { | ||
else { | ||
common_1.TNS_Player_Log("Failed to abandon audio focus."); | ||
common_1.TNS_Player_Log('Failed to abandon audio focus.'); | ||
} | ||
this._mOnAudioFocusChangeListener = null; | ||
}; | ||
TNSPlayer.prototype._getAndroidContext = function () { | ||
var _this = this; | ||
var ctx = app.android.context; | ||
if (ctx === null) { | ||
setTimeout(function () { | ||
_this._getAndroidContext(); | ||
}, 200); | ||
return; | ||
} | ||
else { | ||
return ctx; | ||
} | ||
}; | ||
return TNSPlayer; | ||
@@ -382,0 +398,0 @@ }()); |
@@ -36,3 +36,3 @@ "use strict"; | ||
var _this = this; | ||
if (explanation === void 0) { explanation = ""; } | ||
if (explanation === void 0) { explanation = ''; } | ||
return new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () { | ||
@@ -44,6 +44,4 @@ var error_1; | ||
_a.trys.push([0, 2, , 3]); | ||
return [4, permissions | ||
.requestPermission(android.Manifest.permission.RECORD_AUDIO) | ||
.catch(function (err) { | ||
common_1.TNS_Recorder_Log("Error getting RECORD_AUDIO permission.", err); | ||
return [4, permissions.requestPermission(android.Manifest.permission.RECORD_AUDIO).catch(function (err) { | ||
common_1.TNS_Recorder_Log('Error getting RECORD_AUDIO permission.', err); | ||
reject(err); | ||
@@ -57,3 +55,3 @@ })]; | ||
error_1 = _a.sent(); | ||
common_1.TNS_Recorder_Log("requestRecordPermission error", error_1); | ||
common_1.TNS_Recorder_Log('requestRecordPermission error', error_1); | ||
reject(error_1); | ||
@@ -80,3 +78,3 @@ return [3, 3]; | ||
console.log(err); | ||
reject("Permission to record audio is not granted."); | ||
reject('Permission to record audio is not granted.'); | ||
})]; | ||
@@ -89,13 +87,13 @@ case 1: | ||
else { | ||
common_1.TNS_Recorder_Log("recorder is not initialized, creating new instance of android MediaRecorder."); | ||
common_1.TNS_Recorder_Log('recorder is not initialized, creating new instance of android MediaRecorder.'); | ||
this._recorder = new android.media.MediaRecorder(); | ||
} | ||
audioSource = options.source ? options.source : 0; | ||
common_1.TNS_Recorder_Log("setting audio source", audioSource); | ||
common_1.TNS_Recorder_Log('setting audio source', audioSource); | ||
this._recorder.setAudioSource(audioSource); | ||
outFormat = options.format ? options.format : 0; | ||
common_1.TNS_Recorder_Log("setting output format", outFormat); | ||
common_1.TNS_Recorder_Log('setting output format', outFormat); | ||
this._recorder.setOutputFormat(outFormat); | ||
encoder = options.encoder ? options.encoder : 0; | ||
common_1.TNS_Recorder_Log("setting audio encoder", encoder); | ||
common_1.TNS_Recorder_Log('setting audio encoder', encoder); | ||
this._recorder.setAudioEncoder(encoder); | ||
@@ -146,3 +144,3 @@ if (options.channels) { | ||
if (_this._recorder) { | ||
common_1.TNS_Recorder_Log("pausing recorder..."); | ||
common_1.TNS_Recorder_Log('pausing recorder...'); | ||
_this._recorder.pause(); | ||
@@ -153,3 +151,3 @@ } | ||
catch (ex) { | ||
common_1.TNS_Recorder_Log("pause error", ex); | ||
common_1.TNS_Recorder_Log('pause error', ex); | ||
reject(ex); | ||
@@ -164,3 +162,3 @@ } | ||
if (_this._recorder) { | ||
common_1.TNS_Recorder_Log("resuming recorder..."); | ||
common_1.TNS_Recorder_Log('resuming recorder...'); | ||
_this._recorder.resume(); | ||
@@ -171,3 +169,3 @@ } | ||
catch (ex) { | ||
common_1.TNS_Recorder_Log("resume error", ex); | ||
common_1.TNS_Recorder_Log('resume error', ex); | ||
reject(ex); | ||
@@ -182,3 +180,3 @@ } | ||
if (_this._recorder) { | ||
common_1.TNS_Recorder_Log("stopping recorder..."); | ||
common_1.TNS_Recorder_Log('stopping recorder...'); | ||
_this._recorder.stop(); | ||
@@ -189,3 +187,3 @@ } | ||
catch (ex) { | ||
common_1.TNS_Recorder_Log("stop error", ex); | ||
common_1.TNS_Recorder_Log('stop error', ex); | ||
reject(ex); | ||
@@ -199,3 +197,3 @@ } | ||
try { | ||
common_1.TNS_Recorder_Log("disposing recorder..."); | ||
common_1.TNS_Recorder_Log('disposing recorder...'); | ||
if (_this._recorder) { | ||
@@ -208,3 +206,3 @@ _this._recorder.release(); | ||
catch (ex) { | ||
common_1.TNS_Recorder_Log("dispose error", ex); | ||
common_1.TNS_Recorder_Log('dispose error', ex); | ||
reject(ex); | ||
@@ -211,0 +209,0 @@ } |
@@ -1,2 +0,2 @@ | ||
"use strict"; | ||
'use strict'; | ||
global.__awaiter = | ||
@@ -16,3 +16,3 @@ (this && this.__awaiter) || | ||
try { | ||
step(generator["throw"](value)); | ||
step(generator['throw'](value)); | ||
} | ||
@@ -54,9 +54,6 @@ catch (e) { | ||
if (f) | ||
throw new TypeError("Generator is already executing."); | ||
throw new TypeError('Generator is already executing.'); | ||
while (_) | ||
try { | ||
if (((f = 1), | ||
y && | ||
(t = y[op[0] & 2 ? "return" : op[0] ? "throw" : "next"]) && | ||
!(t = t.call(y, op[1])).done)) | ||
if (((f = 1), y && (t = y[op[0] & 2 ? 'return' : op[0] ? 'throw' : 'next']) && !(t = t.call(y, op[1])).done)) | ||
return t; | ||
@@ -83,4 +80,3 @@ if (((y = 0), t)) | ||
default: | ||
if (!((t = _.trys), (t = t.length > 0 && t[t.length - 1])) && | ||
(op[0] === 6 || op[0] === 2)) { | ||
if (!((t = _.trys), (t = t.length > 0 && t[t.length - 1])) && (op[0] === 6 || op[0] === 2)) { | ||
_ = 0; | ||
@@ -87,0 +83,0 @@ continue; |
@@ -18,3 +18,3 @@ "use strict"; | ||
if (TNSPlayerUtil.debug) { | ||
console.log("TNSPlayer", args); | ||
console.log('NativeScript-Audio - TNSPlayer', args); | ||
} | ||
@@ -35,3 +35,3 @@ }; | ||
if (TNSRecorderUtil.debug) { | ||
console.log("TNSRecorder", args); | ||
console.log('NativeScript-Audio - TNSRecorder', args); | ||
} | ||
@@ -41,4 +41,4 @@ }; | ||
var isURL = false; | ||
if (value.indexOf("://") !== -1) { | ||
if (value.indexOf("res://") === -1) { | ||
if (value.indexOf('://') !== -1) { | ||
if (value.indexOf('res://') === -1) { | ||
isURL = true; | ||
@@ -63,5 +63,5 @@ } | ||
var audioPath = void 0; | ||
var fileName = types_1.isString(path) ? path.trim() : ""; | ||
if (fileName.indexOf("~/") === 0) { | ||
fileName = fs.path.join(fs.knownFolders.currentApp().path, fileName.replace("~/", "")); | ||
var fileName = types_1.isString(path) ? path.trim() : ''; | ||
if (fileName.indexOf('~/') === 0) { | ||
fileName = fs.path.join(fs.knownFolders.currentApp().path, fileName.replace('~/', '')); | ||
audioPath = fileName; | ||
@@ -68,0 +68,0 @@ } |
@@ -1,2 +0,2 @@ | ||
import { Observable } from "tns-core-modules/data/observable"; | ||
import { Observable } from 'tns-core-modules/data/observable'; | ||
@@ -320,6 +320,6 @@ export interface AudioPlayerOptions { | ||
export interface IAudioPlayerEvents { | ||
seek: "seek"; | ||
paused: "paused"; | ||
started: "started"; | ||
seek: 'seek'; | ||
paused: 'paused'; | ||
started: 'started'; | ||
} | ||
export const AudioPlayerEvents: IAudioPlayerEvents; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var common_1 = require("../common"); | ||
var utils = require("tns-core-modules/utils/utils"); | ||
var types_1 = require("tns-core-modules/utils/types"); | ||
var file_system_1 = require("tns-core-modules/file-system"); | ||
var utils = require("tns-core-modules/utils/utils"); | ||
var common_1 = require("../common"); | ||
var TNSPlayer = (function (_super) { | ||
@@ -72,9 +72,7 @@ __extends(TNSPlayer, _super); | ||
var audioPath = void 0; | ||
var fileName = types_1.isString(options.audioFile) | ||
? options.audioFile.trim() | ||
: ""; | ||
if (fileName.indexOf("~/") === 0) { | ||
fileName = file_system_1.path.join(file_system_1.knownFolders.currentApp().path, fileName.replace("~/", "")); | ||
var fileName = types_1.isString(options.audioFile) ? options.audioFile.trim() : ''; | ||
if (fileName.indexOf('~/') === 0) { | ||
fileName = file_system_1.path.join(file_system_1.knownFolders.currentApp().path, fileName.replace('~/', '')); | ||
} | ||
common_1.TNS_Player_Log("fileName", fileName); | ||
common_1.TNS_Player_Log('fileName', fileName); | ||
_this._completeCallback = options.completeCallback; | ||
@@ -85,12 +83,12 @@ _this._errorCallback = options.errorCallback; | ||
var output = audioSession.currentRoute.outputs.lastObject.portType; | ||
common_1.TNS_Player_Log("output", output); | ||
common_1.TNS_Player_Log('output', output); | ||
if (output.match(/Receiver/)) { | ||
try { | ||
audioSession.setCategoryError(AVAudioSessionCategoryPlayAndRecord); | ||
audioSession.overrideOutputAudioPortError(AVAudioSessionPortOverrideSpeaker); | ||
audioSession.overrideOutputAudioPortError(1936747378); | ||
audioSession.setActiveError(true); | ||
common_1.TNS_Player_Log("audioSession category set and active"); | ||
common_1.TNS_Player_Log('audioSession category set and active'); | ||
} | ||
catch (err) { | ||
common_1.TNS_Player_Log("setting audioSession category failed"); | ||
common_1.TNS_Player_Log('setting audioSession category failed'); | ||
} | ||
@@ -107,5 +105,5 @@ } | ||
_this._player.enableRate = true; | ||
common_1.TNS_Player_Log("this._player", _this._player); | ||
common_1.TNS_Player_Log('this._player', _this._player); | ||
if (options.metering) { | ||
common_1.TNS_Player_Log("enabling metering..."); | ||
common_1.TNS_Player_Log('enabling metering...'); | ||
_this._player.meteringEnabled = true; | ||
@@ -163,8 +161,8 @@ } | ||
audioSession.setCategoryError(AVAudioSessionCategoryPlayAndRecord); | ||
audioSession.overrideOutputAudioPortError(AVAudioSessionPortOverrideSpeaker); | ||
audioSession.overrideOutputAudioPortError(1936747378); | ||
audioSession.setActiveError(true); | ||
common_1.TNS_Player_Log("audioSession category set and active"); | ||
common_1.TNS_Player_Log('audioSession category set and active'); | ||
} | ||
catch (err) { | ||
common_1.TNS_Player_Log("setting audioSession category failed"); | ||
common_1.TNS_Player_Log('setting audioSession category failed'); | ||
} | ||
@@ -180,7 +178,7 @@ } | ||
_this._player.delegate = _this; | ||
common_1.TNS_Player_Log("this._player", _this._player); | ||
common_1.TNS_Player_Log('this._player', _this._player); | ||
_this._player.enableRate = true; | ||
_this._player.numberOfLoops = options.loop ? -1 : 0; | ||
if (options.metering) { | ||
common_1.TNS_Player_Log("enabling metering..."); | ||
common_1.TNS_Player_Log('enabling metering...'); | ||
_this._player.meteringEnabled = true; | ||
@@ -212,3 +210,3 @@ } | ||
if (_this._player && _this._player.playing) { | ||
common_1.TNS_Player_Log("pausing player..."); | ||
common_1.TNS_Player_Log('pausing player...'); | ||
_this._player.pause(); | ||
@@ -222,3 +220,3 @@ resolve(true); | ||
} | ||
common_1.TNS_Player_Log("pause error", ex); | ||
common_1.TNS_Player_Log('pause error', ex); | ||
reject(ex); | ||
@@ -233,3 +231,3 @@ } | ||
if (!_this.isAudioPlaying()) { | ||
common_1.TNS_Player_Log("player play..."); | ||
common_1.TNS_Player_Log('player play...'); | ||
_this._player.play(); | ||
@@ -243,3 +241,3 @@ resolve(true); | ||
} | ||
common_1.TNS_Player_Log("play error", ex); | ||
common_1.TNS_Player_Log('play error', ex); | ||
reject(ex); | ||
@@ -251,3 +249,3 @@ } | ||
if (this._player) { | ||
common_1.TNS_Player_Log("resuming player..."); | ||
common_1.TNS_Player_Log('resuming player...'); | ||
this._player.play(); | ||
@@ -258,3 +256,3 @@ } | ||
if (this._player) { | ||
common_1.TNS_Player_Log("playAtTime", time); | ||
common_1.TNS_Player_Log('playAtTime', time); | ||
this._player.playAtTime(time); | ||
@@ -268,3 +266,3 @@ } | ||
if (_this._player) { | ||
common_1.TNS_Player_Log("seekTo", time); | ||
common_1.TNS_Player_Log('seekTo', time); | ||
_this._player.currentTime = time; | ||
@@ -275,3 +273,3 @@ resolve(true); | ||
catch (ex) { | ||
common_1.TNS_Player_Log("seekTo error", ex); | ||
common_1.TNS_Player_Log('seekTo error', ex); | ||
reject(ex); | ||
@@ -285,3 +283,3 @@ } | ||
try { | ||
common_1.TNS_Player_Log("disposing TNSPlayer..."); | ||
common_1.TNS_Player_Log('disposing TNSPlayer...'); | ||
if (_this._player && _this.isAudioPlaying()) { | ||
@@ -297,3 +295,3 @@ _this._player.stop(); | ||
} | ||
common_1.TNS_Player_Log("dispose error", ex); | ||
common_1.TNS_Player_Log('dispose error', ex); | ||
reject(ex); | ||
@@ -311,3 +309,3 @@ } | ||
var duration = _this._player ? _this._player.duration : 0; | ||
common_1.TNS_Player_Log("audio track duration", duration); | ||
common_1.TNS_Player_Log('audio track duration', duration); | ||
resolve(duration.toString()); | ||
@@ -319,3 +317,3 @@ } | ||
} | ||
common_1.TNS_Player_Log("getAudioTrackDuration error", ex); | ||
common_1.TNS_Player_Log('getAudioTrackDuration error', ex); | ||
reject(ex); | ||
@@ -327,3 +325,3 @@ } | ||
if (this._player && speed) { | ||
if (typeof speed === "string") { | ||
if (typeof speed === 'string') { | ||
speed = parseFloat(speed); | ||
@@ -330,0 +328,0 @@ } |
@@ -40,6 +40,6 @@ "use strict"; | ||
var 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"); | ||
recordSetting.setValueForKey(NSNumber.numberWithInt(kAudioFormatMPEG4AAC), 'AVFormatIDKey'); | ||
recordSetting.setValueForKey(NSNumber.numberWithInt(64), 'AVEncoderAudioQualityKey'); | ||
recordSetting.setValueForKey(NSNumber.numberWithFloat(16000.0), 'AVSampleRateKey'); | ||
recordSetting.setValueForKey(NSNumber.numberWithInt(1), 'AVNumberOfChannelsKey'); | ||
errorRef_1 = new interop.Reference(); | ||
@@ -64,3 +64,3 @@ var url = NSURL.fileURLWithPath(options.filename); | ||
catch (ex) { | ||
common_1.TNS_Recorder_Log("start error", ex); | ||
common_1.TNS_Recorder_Log('start error', ex); | ||
reject(ex); | ||
@@ -75,3 +75,3 @@ } | ||
if (_this._recorder) { | ||
common_1.TNS_Recorder_Log("pausing recorder..."); | ||
common_1.TNS_Recorder_Log('pausing recorder...'); | ||
_this._recorder.pause(); | ||
@@ -82,3 +82,3 @@ } | ||
catch (ex) { | ||
common_1.TNS_Recorder_Log("pause error", ex); | ||
common_1.TNS_Recorder_Log('pause error', ex); | ||
reject(ex); | ||
@@ -93,3 +93,3 @@ } | ||
if (_this._recorder) { | ||
common_1.TNS_Recorder_Log("resuming recorder..."); | ||
common_1.TNS_Recorder_Log('resuming recorder...'); | ||
_this._recorder.record(); | ||
@@ -100,3 +100,3 @@ } | ||
catch (ex) { | ||
common_1.TNS_Recorder_Log("resume error", ex); | ||
common_1.TNS_Recorder_Log('resume error', ex); | ||
reject(ex); | ||
@@ -111,3 +111,3 @@ } | ||
if (_this._recorder) { | ||
common_1.TNS_Recorder_Log("stopping recorder..."); | ||
common_1.TNS_Recorder_Log('stopping recorder...'); | ||
_this._recorder.stop(); | ||
@@ -119,3 +119,3 @@ } | ||
catch (ex) { | ||
common_1.TNS_Recorder_Log("stop error", ex); | ||
common_1.TNS_Recorder_Log('stop error', ex); | ||
reject(ex); | ||
@@ -130,3 +130,3 @@ } | ||
if (_this._recorder) { | ||
common_1.TNS_Recorder_Log("disposing recorder..."); | ||
common_1.TNS_Recorder_Log('disposing recorder...'); | ||
_this._recorder.stop(); | ||
@@ -141,3 +141,3 @@ _this._recorder.meteringEnabled = false; | ||
catch (ex) { | ||
common_1.TNS_Recorder_Log("dispose error", ex); | ||
common_1.TNS_Recorder_Log('dispose error', ex); | ||
reject(ex); | ||
@@ -144,0 +144,0 @@ } |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.AudioPlayerEvents = { | ||
seek: "seek", | ||
paused: "paused", | ||
started: "started" | ||
seek: 'seek', | ||
paused: 'paused', | ||
started: 'started' | ||
}; | ||
//# sourceMappingURL=options.js.map |
{ | ||
"name": "nativescript-audio", | ||
"version": "4.3.4", | ||
"version": "4.3.5", | ||
"description": "NativeScript plugin to record and play audio.", | ||
@@ -34,2 +34,3 @@ "main": "audio", | ||
"prepublishOnly": "npm run build", | ||
"precommit": "lint-staged", | ||
"development.setup": "npm run setup && npm link && cd ../demo && npm link nativescript-floatingactionbutton && cd ../src", | ||
@@ -147,11 +148,11 @@ "generate.typings.ios": "cd ../demo && TNS_DEBUG_METADATA_PATH=\"$(pwd)/metadata\" tns build ios && TNS_TYPESCRIPT_DECLARATIONS_PATH=\"$(pwd)/typings\" tns build ios && echo 'Now look for your library typings in demo/typings!'" | ||
"devDependencies": { | ||
"husky": "^0.13.4", | ||
"lint-staged": "^3.6.1", | ||
"prettier": "^1.4.4", | ||
"tns-core-modules": "^3.1.0", | ||
"tns-platform-declarations": "^3.1.0", | ||
"husky": "^0.14.3", | ||
"lint-staged": "^7.0.4", | ||
"prettier": "^1.12.1", | ||
"tns-core-modules": "^4.0.0", | ||
"tns-platform-declarations": "^4.0.0", | ||
"rimraf": "^2.5.0", | ||
"tslint": "~5.4.3", | ||
"typescript": "~2.5.3" | ||
"tslint": "~5.9.1", | ||
"typescript": "~2.8.1" | ||
} | ||
} |
62530
1544