Sharing audio file in whatsapp only transfers the first second

0

My problem is as follows.

I generate an audio file (.wav) from my application and share it through an intent .. but by doing it via whatsapp only 1 sec of audio is sent. When the email is sent correctly, the complete file is sent.

Any ideas that may be failing?

The file I keep in the folder "/storage/emulated/0/Download/prueba1.wav"

public void startShare() {
    File f = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS)+ "//prueba1.wav");
    Log.d("SHARE FILE", "File: " + f);
    Uri uri = Uri.parse("file://" + f.getAbsolutePath());
    Intent share = new Intent(Intent.ACTION_SEND);
    share.putExtra(Intent.EXTRA_STREAM, uri);
    share.setType("audio/mp3");
    share.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
    this.startActivity(Intent.createChooser(share, "Share audio File"));

}

Slds.

UPDATE: It is not a second of audio what WhatsApp sends, but approximately half the duration of the Wav. I think the problem is in the Wav format that uses synthesizeToFile, since I try to send the file generated by my application directly from WhatsApp with the same problem. On the other hand, when I converted it to MP3, I was able to send it without problems.

Thank you very much for your comments, I will continue investigating.

Slds.

    
asked by jabattaglia 29.01.2017 в 03:20
source

1 answer

0

Use the mime type defined for a .wav file:

share.setType("audio/wav");

Do not forget to define the permission:

   <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    
answered by 29.01.2017 в 09:07