Jump to content

iOS Cordova sound issues


paleRider
 Share

Recommended Posts

Hi there:

I have a BJS development in production that works great in all platform but iOS-Cordova app.

In this last configuration the sound doesn't work at all, dumping the following error message:

5ac144c2b05b9_Capturadepantalla2018-04-01alas22_42_52.thumb.png.c50c5092c65ced07ac273e9eee1b8e65.png

Any clues on this?

Thanks for your time.

Link to comment
Share on other sites

Hi PsichiX:

Tomorrow in the morning (CET) I'll be back in the office, able to show that (very simple) lines of code.

Anytime please consider that the code is working flawless in browsers (Win, macOS and Linux) and Android Cordova hybrid app, and only failing in iOS Cordova hybrid app.

Thanks for your time. Best regards.

Link to comment
Share on other sites

Well, my (really-simple) sound related code lines are these:

var _Sfx=new BABYLON.Sound("sfx","assets/sounds/sfx.mp3",_Scene,null,{
  autoplay: false,
  loop: true,
  volume: 0}
);

...

function _updateVolume(param){
  ...		
  //
  _Sfx.setVolume(param);
}

As said, it works on:

  1. desktop - Windows - web - FF
  2. desktop - Windows - web - Chrome 
  3. desktop - macOSX - web - Safari
  4. mobile - Android - web - Chrome
  5. mobile - Android - hybrid app (Cordova)
  6. mobile - iOS - web - Safari

But not in mobile - iOS - hybrid app (Cordova).

Best regards.

Link to comment
Share on other sites

One thing I am pretty sure works is converting to inline Javascript with a Base64 encoded audio buffer.  The decoding in the Javascript is very minor, but built into the QI extension to reduce amount of code generated.  I have a page which will either record off mic or bring in files for conversion.  When using the mp3 decoder to bring in files, they will be sampled at the highest rate your desktop hardware supports, even if lower in the actual .mp3 file.  You can down sample when writing script to reverse this.

You would no longer be at the mercy of the platform.  At times that can be a very good idea.

audiorecorder.jpg.b008d2019f99a5473f6eeef77dd4065d.jpg

Link to comment
Share on other sites

Hi JCPalmer:

Well, as Deltakosh wrote this is a problem related with the way Cordova-iOS manages the local storage XHR resources.

Anyway, when I use a web-served URI, the error is gone (so I suppose the mp3 is loaded) but sadly no sound is produced.

Link to comment
Share on other sites

Well, this is embarrasing... the case is that my problem with remote served mp3 not "sounding" was only due to the infamous Side Switch.

It was turned off. :mellow:

The confusing thing was that movies and music were played w/o problem (?) and so I didn't realized it was off.

Link to comment
Share on other sites

Well, only as a epilogue for this (already closed) issue, I finally managed  to have my DDS local file working on iOS. Please see related thread:

...with the help of cordova-plugin-wkwebview-file-xhr.

Sadly, against the expected, that is not the same with the other XHR-loaded asset of my app, the MP3 local file, so I get the following Xcode error output on it:

2018-04-04 16:43:53.758536+0200 ERROR: BJS - [16:43:53]: error on XHR request.
2018-04-04 16:43:53.760983+0200 xhr-polyfill.js - exception delivering event {"isTrusted":false} TypeError: Argument 1 ('audioData') to webkitAudioContext.decodeAudioData must be an instance of ArrayBuffer

Oracle's guys says me that it's because "...the babylon code is not setting the XMLHttpRequest responseType to "arraybuffer". The polyfill with this plugin only has a small list of file suffixes to default response types. The native XMLHttpRequest probably defaults "arraybuffer" based on the URL suffix but we are defaulting to text."

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...