B4J Question GameViewHelper. PlayAudioClip (Mp3File, x) lacks StopPlay or/and End during playback

johnerikson

Active Member
Licensed User
I use GameViewHelper.PlayaudioClip to play background music to pictures.
Does anybody know if/how playback can be stopped before it runs out?
 

johnerikson

Active Member
Licensed User
Thanks!
Have tried with MediaPlayer. It's just that I don't get MediaPlayer to work at all.
Unable to initialize Mediplayer. These are some unsuccessful attempts

B4X:
Private MP As MediaPlayer
‘……………..
    'sDirData = File.DirData("")' = C:\Users\JohnErik\AppData\Roaming   'moved the file .mp3 here
    'MP.Initialize("Complete",  File.GetUri( File.DirData (""),  "Stardust.mp3"))
    'MP.Initialize("Complete",  File.GetUri( sDirData ,  "Stardust.mp3"))
    ' Result:java.lang.IllegalStateException: Toolkit not initialized for both
    
    'sGetUri = File.GetUri( "", "Stardust.mp3") '= file:/D:/Program/B4J/Server/ABMServer/EasyMedia/Objects/Stardust.mp3
    'MP.Initialize("Complete",   sGetUri)  'moved the file .mp3 ubder objects
    'Result: java.lang.IllegalStateException: Toolkit not initialized
    
    'sGetUri = "File:/D:/Program/B4J/Server/ABMServer/EasyMedia/Objects/www/easymedia/EasyVideos/Audio" & PG_UserID & "/Stardust.mp3"
    'MP.Initialize("Complete", sGetUri)
    'Result: java.lang.IllegalStateException: Toolkit not initialized
    
    'MP.Initialize("Complete", File.geturi(File.DirAssets, "Stardust.mp3"))
    'Result: java.lang.IllegalStateException: Toolkit not initialized
The same errors on all options. Maybe something very simple goes wrong!
I have been looking for examples in the forum, but it has not helped me!
However, GameViewHelper is super Simple but missing the stop/end!

I am very grateful for a completely example, I work now with a non-io Project [ABMaterial].
 

johnerikson

Active Member
Licensed User
Thanks for the information!

I suspected it, I am not able to safely determine if the examples in the forum are UI or non-UI!, so back to PlayaudioClip if there are no other options. I am allowed to prepare the length of the MP3 files.
 

johnerikson

Active Member
Licensed User
Many thanks!

Erel, you are a star, exactly what I needed!
I understand you fix it now, you couldn't have done it faster and better!
 

OliverA

Expert
Licensed User
Top