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

Recorded file neither saving nor playing #301

Open
mayankkataria opened this issue Jan 25, 2021 · 13 comments
Open

Recorded file neither saving nor playing #301

mayankkataria opened this issue Jan 25, 2021 · 13 comments

Comments

@mayankkataria
Copy link

mayankkataria commented Jan 25, 2021

I'm using this plugin with ionic capacitor instead of cordova with command ionic cap sync.
My code:

audioFile: MediaObject;
constructor(private media: Media, private plt: Platform, private file: File) {}
ionViewDidEnter() {
    this.plt.ready()
    .then(() => {
      setTimeout(() => {
        this.audioFile = this.media.create(this.file.externalRootDirectory + 'audiofile.mp3');
        this.audioFile.onStatusUpdate.subscribe(status => console.log('status: ', status));
        this.audioFile.onSuccess.subscribe(() => console.log('Action is successful'));
        this.audioFile.onError.subscribe(error => console.log('Error: ', error));
      }, 1000);
    })
    .catch(err => console.log('ready error: ', err));
}

record() {
    // When record button clicked
    this.audioFile.startRecord();
}

stop() {
    // When stop button clicked
    this.audioFile.stopRecord();
    this.audioFile.play();
}

When I clicked record, output was: Error: 1 and when I stopped recording than the output was status: 4 and Action is successful
I expected to either play the recording or get audiofile.mp3 in file manager of my android device but I didn't got any of it.

@zubinraja
Copy link

Facing same issue for android 10+ SDK 30.
As per doc error:1 refers to MediaError.MEDIA_ERR_ABORTED = 1

@jahertor
Copy link

jahertor commented Mar 1, 2021

Same on iOS 14 with Ionic Capacitor:

Log just says:
Media create INVALID
Media startRecordingAudio INVALID
Media stopRecordingAudio INVALID

Couldn't catch any other log from exceptions nor catching error promises, so I don't know how to proceed.

@BLTowsen
Copy link

Hi guys not sure if this might help the android guys but worked for me

Go into the android project AndroidManifest.xml file.
Place the following tag: android:requestLegacyExternalStorage="true"

Like so inside the application tag:

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/AppTheme"
        android:usesCleartextTraffic="true"
        android:requestLegacyExternalStorage="true">

@quauhtlimtz
Copy link

Same situation here. Can't find any more information.

@Kerulener
Copy link

same..

@francoisduchemin
Copy link

This solution with the "requestLegacyExternalStorage" is soon going to be an issue.

https://developer.android.com/about/versions/11/privacy/storage

If I understand correctly, our apps won't be able to write to the external directory so easily anymore...

@fgarcia5
Copy link

fgarcia5 commented Jun 9, 2021

Same issue here in Android API 30.

Any workaround to fix it?

android:requestLegacyExternalStorage="true" not work for me.

Thanks!

@21pg
Copy link

21pg commented Sep 28, 2021

Same issue here in Android API 30.

Any workaround to fix it?

android:requestLegacyExternalStorage="true" not work for me.

Thanks!

Did you find any solution ??

@jahertor
Copy link

jahertor commented Sep 28, 2021

Same issue here in Android API 30.
Any workaround to fix it?
android:requestLegacyExternalStorage="true" not work for me.
Thanks!

Did you find any solution ??

In my case my app required this feature, so I ended up developing my app with Flutter. You can make yourself an idea on how many time I spent trying to solve this particular problem.

@francoisduchemin
Copy link

I also don't have any solution unfortunately... I cannot update my Android app right now.

@zubinraja
Copy link

for android instead of this.file.externalRootDirectory try this.file.externalDataDirectory. it works for me.
For android and iOS this directory works for me
this.global.G_ExternalDirectory = this.platform.is('ios') ? this.file.dataDirectory : this.file.externalDataDirectory;

in addition to it, before audio recording I am checking audio and storage access permission explicitly.

this.diagnostic.requestMicrophoneAuthorization() and
this.diagnostic.requestExternalStorageAuthorization()

see if that works for you too.

@21pg
Copy link

21pg commented Sep 29, 2021

In my case my app required this feature, so I ended up developing my app with Flutter. You can make yourself an idea on how many time I spent trying to solve this particular problem.

Nothing works for me..
I Have an app builder, In which 20K apps that depends on this plugin (required this feature)-
I don't required to record and play.
We use live stream e.g (-[(http://streams.radiobob.de/bob-chillout/aac-64/streams.radiobob.de/)])
and just want to play this audio stream on button click..
When I click play button, output is: Error: 1

#315

@bhandaribhumin
Copy link

@zubinraja Thanks for you solution but not working for me. Still figure out .
@21pg agreed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

10 participants