I use Erel's code sample "beep" to create code playing audio via the AudioStreamer. It works already, but now I had a crash without any debug feedback, the smartphone hang. So I asked me, whether my way is already correct. On the other side I do not really understand the co-operation of MAIN() and STARTER().
Every second I tranfer new Bytes to the already open AudioStreamer.
that is what I'm doing:
Now my Questions are:
1. Do I need to stop the AudioStreamer, when I finish the app? For me it is important to keep the player open during app is open. So I cannot add a NULL byte at the end of the transfered Byte()-Array like Erel suggested in his example.
2. And where can I add the code for stopping it?
3. How can I react on Events from the AudioStreamer? Which events are avaiable? Why can I not see the possible Event-related Subs of the AudioStreamer in my code? It looks like the AudioStreamer is unknown in my MAIN.
Every second I tranfer new Bytes to the already open AudioStreamer.
that is what I'm doing:
MAIN:
...
Sub SendMoreSamples
....
Private AudioOutBytes() As Byte
' fill them
....
CallSub2(Starter, "SendToAudio", AudioOutBytes)
End Sub
STARTER:
#Region Service Attributes
#StartAtBoot: False
#ExcludeFromLibrary: True
#End Region
Sub Process_Globals
Public AudioOut As AudioStreamer
End Sub
Sub Service_Create
AudioOut.Initialize("AudioOut",22100,True,16,AudioOut.VOLUME_MUSIC)
AudioOut.StartPlaying
End Sub
Public Sub SendToAudio(Bytes() As Byte)
AudioOut.Write(Bytes)
End Sub
Sub Service_Start (StartingIntent As Intent)
Service.StopAutomaticForeground
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
Now my Questions are:
1. Do I need to stop the AudioStreamer, when I finish the app? For me it is important to keep the player open during app is open. So I cannot add a NULL byte at the end of the transfered Byte()-Array like Erel suggested in his example.
2. And where can I add the code for stopping it?
3. How can I react on Events from the AudioStreamer? Which events are avaiable? Why can I not see the possible Event-related Subs of the AudioStreamer in my code? It looks like the AudioStreamer is unknown in my MAIN.