Android Question Send mp3 to Whatsapp out of B4A Program

h725

Active Member
Licensed User
Longtime User
Hello community,

1. I have a song in the files manager called "song.mp3".

2. I have a simple routine, playing an mp3:

Song:
Sub btnplaysong_click

        mp.Load(File.DirAssets, song.mp3)
        mp.Play
        
End Sub

I would like to implement the following function: If I use
the method "Sub btnplaysong_longclick" the mp3 from
the files manager should be handed over to whatsapp.
It would also be possible to open the "share with" dialog
in Android (I do not know the professionell designation):

sharewith.png


Does anybody has an idea?

Kind regards
h725
 

ilan

Expert
Licensed User
Longtime User
see this:

 
Upvote 0

h725

Active Member
Licensed User
Longtime User
Thank you for the fast response.
I tried this and it working fine:

btnplaysong_longclick:
Sub btnplaysong_longclick
    File.Copy(File.DirAssets, "song.mp3", Provider.SharedFolder, "song.mp3")

    Dim in As Intent
    in.Initialize(in.ACTION_SEND, "")
    in.SetPackage("com.whatsapp")
    in.setType("audio/3gp|audio/AMR|audio/mp3")
    in.PutExtra("android.intent.extra.STREAM", Provider.GetFileUri(FileToSend))
    in.Flags = 1 'FLAG_GRANT_READ_URI_PERMISSION   
    StartActivity(in)   
End Sub

Is it possible to change the name of the mp3file which shows up in the whatsapp-chat?

Thank you
h725
 
Upvote 0

ilan

Expert
Licensed User
Longtime User
Is it possible to change the name of the mp3file which shows up in the whatsapp-chat?

yes here you can change it:

B4X:
 File.Copy(File.DirAssets, "song.mp3", Provider.SharedFolder, "NEWFILENAME.mp3")

when you copy the file you can give it a new name
 
Upvote 0

Peter Simpson

Expert
Licensed User
Longtime User
Somehow this does not work:

View attachment 152170

I would like to change AUD- etc.
I found that whatsapp changed the audio file name automatically. If you were to comment out the line SetPackage and select email for example, you will notice that the attached file name will be song.mp3 and not whatever whatsapp has changed it to. Yes I know it's a pain.

I once read somewhere on the net that if one of the track tags (metadata) is present (in this case with the file name) then whatsapp will display whatever is in that tag (don't ask me which tag (metadata)). I came across this issue before, but luckily I didn't need to fix the name change issue so I just ignored it as my client didn't need the file name name to be correct, just the working audio files.

Anyway, II read it was because one of the audio file properties is blank.


Enjoy...
 
Upvote 0
Top