1

Hi I'm developing an Hybrid Application in Cordova. I would like to reproduce an audio from the application. I obtained error using:

  1. Audio Tag inside html
  2. Audio javascript object
  3. Ionic NativeAudio

I also tried to download file and to reproduce it but when I can download I can only on some folder, to reproduce file only other folder.

EDIT some code: where if I open the url from chrome or firefox or VLC I can hear correctly the sound Il browser non supporta l'audio

Javascript code: and url is the same of above

this.stream = new Audio(url);

this.stream.addEventListener('playing', (data) => {
  console.log(data);
});

this.stream.addEventListener('error', (error) => {
  console.log(error);
});
this.stream.play();

In console I obtain:

Event {isTrusted: true, type: "playing", target: audio, currentTarget: audio, eventPhase: 2…}bubbles: falsecancelBubble: falsecancelable: truecurrentTarget: nulldefaultPrevented: falseeventPhase: 0isTrusted: trueisTrusted: truepath: Array[1]returnValue: truesrcElement: nulltarget: nulltimeStamp: 5007452.3950000005type: "playing"__proto__: Event
francesca-player.ts:35

Event {isTrusted: true, type: "error", target: audio, currentTarget: audio, eventPhase: 2…}bubbles: falsecancelBubble: falsecancelable: truecurrentTarget: nulldefaultPrevented: falseeventPhase: 0isTrusted: trueisTrusted: truepath: Array[1]returnValue: truesrcElement: nulltarget: nulltimeStamp: 5008322.655000001type: "error"__proto__: EventAT_TARGET: 2BLUR: 8192BUBBLING_PHASE: 3CAPTURING_PHASE: 1CHANGE: 32768CLICK: 64DBLCLICK: 128DRAGDROP: 2048FOCUS: 4096KEYDOWN: 256KEYPRESS: 1024KEYUP: 512MOUSEDOWN: 1MOUSEDRAG: 32MOUSEMOVE: 16MOUSEOUT: 8MOUSEOVER: 4MOUSEUP: 2NONE: 0SELECT: 16384bubbles: (...)get bubbles: ()cancelBubble: (...)get cancelBubble: ()set cancelBubble: ()cancelable: (...)get cancelable: ()constructor: Event()currentTarget: (...)get currentTarget: ()defaultPrevented: (...)get defaultPrevented: ()eventPhase: (...)get eventPhase: ()initEvent: initEvent()path: (...)get path: ()preventDefault: preventDefault()returnValue: (...)get returnValue: ()set returnValue: ()srcElement: (...)get srcElement: ()stopImmediatePropagation: stopImmediatePropagation()stopPropagation: stopPropagation()target: (...)get target: ()timeStamp: (...)get timeStamp: ()type: (...)get type: ()Symbol(Symbol.toStringTag): "Event"__proto__: Object

Someone can help me? Daniele

4

1 に答える 1

0

オーディオを録音するには、タグcordova-plugin-media-captureではなくを使用する必要があります。<audio>詳細はこちら: https://www.npmjs.com/package/cordova-plugin-media-capture

また、Watson Speech to Text は特定のオーディオ形式しか受け付けないため、Android の .wav 形式でオーディオを録音する Cordova プラグインを使用することをお勧めします。私はこれを多くの問題なく使用しました: https://github.com/petrica/wav-recorder

于 2016-10-13T13:48:10.427 に答える