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

Download not working!? #13

Open
dillyPamn opened this issue Feb 3, 2017 · 8 comments
Open

Download not working!? #13

dillyPamn opened this issue Feb 3, 2017 · 8 comments

Comments

@dillyPamn
Copy link

Why isnt the download working? ive tried everything including the demo and it doesnt work?

Whats going on?

@CristalT
Copy link

CristalT commented Aug 23, 2017

It's an issue that hasn't responses for me. Looking for a solution I've modified the code to save the audio file to server. Maybe could be useful for you.

Just search "control.save" in angular-audio-recorder.js file ( near line 377 ) and write this:

control.save = function (fileName) {
    if (!service.isAvailable() || status.isRecording || !control.audioModel) {
      return false;
    }

    var formData = new FormData();
    var request = new XMLHttpRequest();
    var content = control.audioModel;
    var blob = new Blob([content], { type: "audio/mp3"});
    formData.append("file", blob);
    request.open("POST", "/app/api/upload/audioMessage.php", true);
    request.send(formData);
  };

Just in case, my uploader php file ( /app/api/upload/audioMessage.php ) is something like this:

<?php
$dest_dir = $_SERVER['DOCUMENT_ROOT'] . '/storage/audio_messages/';
if(!file_exists($dest_dir)) mkdir($dest_dir, 0777);
move_uploaded_file($_FILES['file']['tmp_name'], $dest_dir . uniqid() . ".mp3");

@amirvenus
Copy link

I tried to use CristalT's method but it didn't come to an avail..
This is the error I am getting:

Expression 'undefined' in attribute 'audioModel' used with directive 'ngAudioRecorder' is non-assignable!

Any solutions?

@CristalT
Copy link

CristalT commented Aug 23, 2017

Check the audio-model attribute in your ng-audio-recorder directive, here's mine:

<ng-audio-recorder id="mainAudio" audio-model="recorded" show-player="false" time-limit="timeLimit">

@amirvenus
Copy link

Upon inspecting the browser's Network section (in dev tools) I can see that a wav file is indeed generated.
But I don't know how I would save it.

It appears as data:audio/wav;base64,UklGRiBABwBXQVZF...

so my question is how would I save that file on a remote server.
Thanks

@amirvenus
Copy link

My bad, I had made edits to the js file but was still using the .min version

The last thing I want to know is why is that the page automatically asks for audio permission on page load?

Presumably, request to access audio must happen upon clicking on recordAudio?!?

@CristalT
Copy link

Have you check the configuration of your AngularJS? Have you added all right dependences?

@amirvenus
Copy link

amirvenus commented Aug 24, 2017 via email

@amirvenus
Copy link

For anyone who has the same problem as me (uploaded file is only 4 bytes):

You need to put the block related to upload in $timeout so that there will be enough time to prepare the file.

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

3 participants