Android Question Exoplayer wait listen to play.

Heppy

Active Member
Licensed User
Longtime User
I have an audio server and I want the exoplayer to be constantly listening to play audio. But the server I active giving him a play. I'm doing it with complete and error restarting the exoplayer.

B4X:
Sub Activity_Create(FirstTime As Boolean)
    If FirstTime Then
        sources.Initialize
        sources.Add(player1.CreateURiSource("http://192.168.1.154:8000"))
'        sources.Add(player1.CreateDashSource("http://www.youtube.com/api/manifest/dash/id/bf5bb2419360daf1/source/youtube?as=fmp4_audio_clear,fmp4_sd_hd_clear&sparams=ip,ipbits,expire,source,id,as&ip=0.0.0.0&ipbits=0&expire=19000000000&signature=51AF5F39AB0CEC3E5497CD9C900EBFEAECCCB5C7.8506521BFC350652163895D4C26DEE124209AA9E&key=ik0"))
'        sources.Add(player1.CreateHLSSource("https://devimages.apple.com.edgekey.net/streaming/examples/bipbop_4x3/bipbop_4x3_variant.m3u8"))
'        sources.Add(player1.CreateUriSource("http://html5demos.com/assets/dizzy.mp4"))
        player1.Initialize("player")
        player1.Prepare(player1.CreateListSource(sources))
    End If
    'Activity.LoadLayout("1")
    'SimpleExoPlayerView1.Player = player1
    player1.Play
End Sub

Sub Player_Ready
    Log("Ready")
    ToastMessageShow("Listo para reproducir",False)
End Sub

Sub Player_Error (Message As String)
    Log("Error: " & Message)
    ToastMessageShow("Error, reiniciando",False)
    player1.Release
    player1.Initialize("player")
    player1.Prepare(player1.CreateListSource(sources))
    player1.Play
End Sub

Sub Player_Complete
    Log("complete")
    ToastMessageShow("Reproducción completada",False)
    player1.Release
    player1.Initialize("player")
    player1.Prepare(player1.CreateListSource(sources))
    player1.Play
End Sub

Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub

Thanks
 

DonManfred

Expert
Licensed User
Longtime User
should´nt the
player1.Play in the
B4X:
Sub Player_Ready
    Log("Ready")
    ToastMessageShow("Listo para reproducir",False)
End Sub
Eventsub?

I don´t use it but would expect it here


You probably can use wait for to wait for the Player_Ready event
 
Upvote 0

Heppy

Active Member
Licensed User
Longtime User
My English is very bad and I have not explained myself. I want to start exoplayer and when I decide I give play to the audio server. Therefore exoplayer has to be listening to that address that is local to my computer. I've tried it and if it does not play it does not play. I restart the android program and if it works. I want exoplayer to be listening all the time.

Thanks DonMandred
 
Upvote 0

ac9ts

Active Member
Licensed User
Longtime User
I'm not sure that I understand what you mean. Sorry.

It sounds like the audio server may not always be active and he wants to have ExoPlayer sit and wait until it is.

My experience is that ExoPlayer will error or timeout if the stream isn't available. Maybe another routine that occasionally checks to see if the stream is up and then calls ExoPlayer to start playing?
 
Upvote 0

Heppy

Active Member
Licensed User
Longtime User
Taking advantage of the connection error that I get when trying to join it to the server, I retry it and when it plays the server it connects and it works very well.
I've had it all night and with positive results. I prefer it to MediaPlayerStream

Thanks to all.
 
Upvote 0
Top