Skip to content
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

stop() callback invoked when file doesn't exist #82

Open
giorgiobeggiora opened this issue Feb 5, 2019 · 4 comments
Open

stop() callback invoked when file doesn't exist #82

giorgiobeggiora opened this issue Feb 5, 2019 · 4 comments
Labels
analysis needed This is a question or potential bug that needs further analysis. help wanted The great thing about open-source is that everyone can contribute!

Comments

@giorgiobeggiora
Copy link

The file is not available in the stop() callback, so you need to check if the file exists using a loop that interrupts when the file become available.

Note that if you're using always the same file name you need to always delete the file before to run start() again, otherwise you will use the previous audio file.

const captureCfg = { fileUrl: urlToMyLocalFile }
audioinput.start(captureCfg);
setTimeout(stopRecording, 1000);
function stopRecording () {
  audioinput.stop(function(url){
    console.log(url); // value is "OK"
    window.resolveLocalFileSystemURL(urlToMyLocalFile, function (fileEntry) {
      console.log('file found'); // this doesn't trigger
    }, err => {
      console.log(err.code); // value is 1 ---> FileError.NOT_FOUND_ERR
    });
  });
}
@edimuj edimuj added help wanted The great thing about open-source is that everyone can contribute! analysis needed This is a question or potential bug that needs further analysis. labels Mar 6, 2019
@artorralbaiii
Copy link

Try to have a setTimeOut before you call the window.resolveLocalFileSystemURL.

Because there is a short delay on creating the physical file so when you trying to locate the file, it is not yet created.

@giorgiobeggiora
Copy link
Author

of course that's a possible solution, but I think it's a plugin's job wait for the file creation, and then fire the callback: it should not be a developer's implementation. At least, please write about the delay in the documentation!

@edimuj
Copy link
Owner

edimuj commented Jun 5, 2019

Yes, I agree @giorgiobeggoria, it is something that would be handled by the plugin. Please send a PR with your fix and I'll merge it.

@giorgiobeggiora
Copy link
Author

giorgiobeggiora commented Jun 6, 2019

the problem is that I don't know Java nor any other native language... well, it's time to learn them :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
analysis needed This is a question or potential bug that needs further analysis. help wanted The great thing about open-source is that everyone can contribute!
Projects
None yet
Development

No branches or pull requests

3 participants