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

Can I return the function to know when it's done recording? #28

Open
Snodvod opened this issue May 31, 2016 · 0 comments
Open

Can I return the function to know when it's done recording? #28

Snodvod opened this issue May 31, 2016 · 0 comments

Comments

@Snodvod
Copy link

Snodvod commented May 31, 2016

I want to record something of 30 seconds. In my ionic controller I call the RecordService where your API is used to record, everything works, but I want to return something to my controller once the success function is done... How can I do that?

SERVICE:

.service('RecordService', function (UsersModel, Backand, $cordovaMedia, $q, $cordovaFile, $state) {
    var service = this;

    service.record = function () {
      return window.plugins.audioRecorderAPI.record(function (savedFilePath) {
        var fileName = savedFilePath.split('/')[savedFilePath.split('/').length - 1];

        // Store filename in user object in database

        Backand.getUserDetails().then(function (result) {
          UsersModel.fetch(result.userId).then(function (user) {
            user.data.music = fileName;
            UsersModel.update(result.userId, user.data).then(function (updatedUser) {
              console.log(updatedUser);
              return savedFilePath;
            })
          }, function (error) {
            console.log(error);
          })
        }, function (error) {
          console.log(error);
        });
      }, function (error) {
        console.log("Kapot: " + msg);
        return error;
      }, 30);
    }
  })

CONTROLLER:

function record() {
      rec.recording = true;
      startTimer();
      RecordService.record() // Here do something like .then(function() {bla bla}) ?;
    }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant