Android Question Can I play a wav file in the Starter Service

e3rd

New Member
Licensed User
I want an app that has no GUI - am I right in thinking I can use the Starter Service for this? I want to be able to click my app icon and have the device play a short wav file with nothing happening on-screen.

Creating a new B4A project, I have nothing at all added to the default Main module and the following code in the Starter Service:

Sub Process_Globals
Dim SVMediaPlayer As MediaPlayer
End Sub

Sub Service_Create
SVMediaPlayer.Initialize
End Sub

Sub Service_Start (StartingIntent As Intent)
Service.StopAutomaticForeground 'Starter service can start in the foreground state in some edge cases.
SVMediaPlayer.Load(File.DirAssets,"test.wav")
SVMediaPlayer.Play
End Sub

Sub Service_TaskRemoved
End Sub

Sub Application_Error (Error As Exception, StackTrace As String) As Boolean
Return True
End Sub

Sub Service_Destroy
End Sub

In the logs file, I'm getting a long list of red text, starting with:
java.io.IOException: Prepare failed.: status=0x1

Any suggestions?
 

Erel

Administrator
Staff member
Licensed User
Upvote 0
Top