Play streaming audio with b4j

Play streaming audio with b4j

I exploit this module hier playDataAudio to play knowledge acquired from b4a that use AudioStreamer from b4j


B4X:


Private Sub Astream_NewData (Buffer() As Byte)

log("knowledge arrived")

playaudio.SendDataPlayer(Buffer)


B4X:


Sub Class_Globals
    Private nativeMe As JavaObject
End Sub

'Initializes the item. You can add parameters to this technique if wanted.
Public Sub Initialize

    nativeMe = Me
    nativeMe.RunMethod( "initialaudio", Null)
End Sub

Public Sub StartAudioPlayer
    nativeMe.RunMethod( "startaudio", Null)
End Sub

Public Sub StopAudioPlayer
    nativeMe.RunMethod( "stopaudio", Null)
End Sub

Public Sub SendDataPlayer (knowledge() As Byte)
    
    nativeMe.RunMethod( "playaudio", Array(knowledge,knowledge.Length))
End Sub


#IF JAVA
import javax.sound.sampled.*;

    SourceDataLine _speaker;

    public void initialaudio() throws LineUnavailableException{
        //  specifying the audio format
        AudioFormat _format = new AudioFormat(22050.F,// Sample Rate...

Read extra

HI-FI News

through B4X Programming Forum https://ift.tt/0lZMkuV

August 4, 2025 at 09:53AM