Sub Button1_Click
MediaPlayer1.Initialize
MediaPlayer1.Load(File.DirAssets, "name.mp3")
MediaPlayer1.Play
End Sub
B4A compiles with no problem, but when I run the apk on my device I see:
Error occured
An error has occured in sub:
main_play(java line: 553)
java.io.FileNotFoundException:
name.mp3
Continue?
The message is clear, I've added the .mp3 file by clicking on files (between modules and logs) but nothing has changed...
Try making your app copy it from File.DirAssets to File.DirInternal and play it from there. MediaPlayer can't play it from DirAssets as it it is not a real Folder.
Where is File.DirInternal? :sign0104:
If I just change File.DirAssets in File.DirInternal there's another error:
Error occurred
An error has occured in sub:
main_play(java line: 553)
java.io.IOException: Prepare
failed.: status=0x1
Continue?
If FirstTime Then
If File.Exists(File.DirInternal, "Ronzio.mp3") = False Then
File.Copy(File.DirAssets, "Ronzio.mp3", File.DirInternal, "Ronzio.mp3")
End If
End If
Dim ship, blub as Int
If File.Exists(File.DirDefaultExternal, "Name.mp3") Then
ship = soundfile.Play(blub, 1, 1, 1, 0 , 1)
Else
ToastMessageShow("No sound!¿?!", True)
End If
Deutsch?? Vielleicht zoll Klaus oder einer der anderen Deutschern morgen deine frage sehen oder kunnen Sie die komplete Kode fuer das mp3 zehen lassen?.
Entschuldigung fuer meine Deutsch :BangHead:
Ha, ha, I was so busy trying to write some German I missed the last ones. So skip this post.
Indeed lol, be happy that you are 13, there is a whole world ahead of you.
I will let you comunicate with Xverhelst then, the two of you will understand eachother way better.
Succes and I hope to see that you got the sound running.
Thanks Helen, ciao!
Is it possible to resume instead of restart? If I write MediaPlayer1.Play I don't hear anything, but if I write MediaPlayer1.Load ecc it restarts...
Sub Activity_Resume
If File.Exists(File.DirDefaultExternal, "/SoundVogels/" & Wet.Text & ".mp3") Then
ship = speel.Play(blub, 1, 1, 1, 0 , 1)
Else
ToastMessageShow("Geluid is nog niet beschikbaar", True)
End If
End Sub
Sub Activity_Pause (UserClosed As Boolean)
speel.Stop(ship)
speel.Unload(blub)
ship = 0
End Sub