Low latency plugin working on Meteor 1.2?

Hi there,

I was happily using this plugin before 1.2 and with the upgrade it stopped working

I’m not sure how can I debug or diagnose the possible issue

Here is an example app that I’ve added to show/test this issue:

I’d appreciate any help on getting unstuck otherwise I’ll be forced to downgrade

Whats the specific problem. Doesn’t play on ios? Doesn’t play on android? Both? Won’t load the files? etc.

I’ve had a lot of experience with that plugin and I eventually got rid of it after I’d modified it to meet my needs. For one, its error handling is terrible at best, if you load a file that isnt there, it sometimes just won’t tell you that it couldn’t find the file. It took me forever just to figure that out. Also the algorithm it uses to actually find a file is outdated at best. The cordova-media plugin uses a much better pattern to find your files. So that could be the issue for you. The other issue, which I ran into were the permissions on ios not being set correctly. I had to modify those as well and eventually I did get it to work. All the changes I made had to be done with obj c / java.

Android and iOS. None of them play. They both did before 1.2 so I suspect that it might be a load/permissions problem like you mention.

In the previous version I remember it complaining about file found or not until I got it right, but now, there are no hints on the console log.

I’d try cordova-media maybe it is low latency?

You can try my fork if you want. Its in no way ready for production. But it will at least tell you if the file doesnt exist, or your pointing it to the wrong spot. I had some trouble with file pathing from meteor 1 -> 1.2. Cordova changed their folder structure a little bit I think.

but I would stick to the media plugin unless you need multiple sound channels.

1 Like

My requirement is to play with low latency and I think the media plugin did had a ~40ms lag.

I’ll try again today with it, and if not good your plugin.

Will follow up how it goes

With cordova-media I had 2 problems:

  1. could not create a gapless loop
  2. the instantiated sound after some .play() and .pause() it just stops working.

Code is here in case anyone wants to take a look:

I’m trying with @pmwisdom’s fork of NativeAudio now…

@pmwisdom I’ve discovered that I wasn’t using the error handler and after adding it it revealed that the asset was not found.

I’m using .preloadComplex() and I’ve tried so far:

  1. ‘application/app/audio/apito2.aiff’
  2. ‘app/audio/apito2.aiff’
  3. ‘documents://application/app/audio/apito2.aiff’
  4. ‘documents://app/audio/apito2.aiff’
  5. ‘documents://www/application/app/audio/apito2.aiff’
  6. http://meteor.local/app/audio/apito2.aiff
  7. http://meteor.local/application/app/audio/apito2.aiff
  8. ‘/www/application/app/audio/apito2.aiff’
  9. ‘/application/app/audio/apito2.aiff’
  10. ‘/app/audio/apito2.aiff’

The assets are in meteorRoot/public/audio/ and I can see them in XCode being there

I don’t get how it’s expecting for me to give it the path.

Any clue?

You need to give it the native path.

This is what I use to get that as of meteor 1.2. This should work for both iOS and Android.

var audioPath = 'audio/apito2.aiff';
var path = cordova.file.applicationDirectory + 'www/application/app/' + audioPath ;

You might need to cut the file:// part off of it for the Low Latency plugin, so you could do:

var path = (cordova.file.applicationDirectory + 'www/application/app/' + audioPath).replace('file://', '');
2 Likes

Heres a nifty function I wrote if you want to browse the application directory of your cordova app. You can do so through the inspect devices tab in chrome.

browsePath: function (path) {
    function readDir (dirEntry) {
        var dirReader = dirEntry.createReader();

        // Call the reader.readEntries() until no more results are returned.
        dirReader.readEntries(function (results) {
            console.log("---> CHILDREN OF DIRECTORY:", dirEntry.name);

            results.forEach(function (entry, i) {
                if (entry.isDirectory) {
                    console.log(entry.name);
                    //readDir(entry);
                } else {
                    console.log("File: ", entry.name);
                }
            });
        }, function (error) {
            console.log("readEntries Error:", error);
        });
    }

    window.resolveLocalFileSystemURL(path, readDir,
        function (error) {
            console.log("resolveLocalFileSystemURL Error:", error);
        }
    );
}

And you can use it like so…

 browsePath(cordova.file.applicationDirectory);
1 Like

Amazing answer @pmwisdom! the browsePath is really handy

It didn’t work with the original NativeAudio, it only loaded successfully the assets when using your fork.

You saved the day man. Thank you so much!

No problem. Glad it worked for you!