Android Question MediaPlayerStream stopped after half hour

Juanet

Member
Licensed User
Longtime User
Hi, I am developing an application for an online radio, the problem is that approximately after half an hour the player stops no matter if it is playing in the background or with the application open, the code I use (summarized) is as follows, I appreciate giving me some light to solve this problem, from already thank you very much.

B4X:
Sub Class_Globals
    Private mp As MediaPlayerStream
    Private btn1 As B4XView
End Sub

Public Sub Initialize
'    B4XPages.GetManager.LogEvents = True
End Sub

'This event will be called once, before the page becomes visible.
Private Sub B4XPage_Created (Root1 As B4XView)
    Root = Root1
    Root.LoadLayout("MainPage")

    mp.Initialize("mp")
    mp.Looping = True

End Sub

Private Sub btn1_Click
    mp.Load("https://stream.example.com/stream1")
End Sub

Sub mp_StreamReady
    mp.Play
End Sub
 

MarcoRome

Expert
Licensed User
Longtime User
Try using the other events as well to figure out why it stops.
Is a mistake ? Ended ?


StreamReady
StreamError (ErrorCode As String, ExtraData As Int)
StreamBuffer(Percentage As Int)
Complete

See also:
 
Upvote 0

Juanet

Member
Licensed User
Longtime User
Thanks Erel,

Im downloaded ExoPlayer examples from the link provided and also additional libraries and put then in the shared libs, but is imposibble to work with that because added libraries not show in B4A and i think thats because XML's files doesnĀ“t exists.

MarcoRome,

Im trying with the events listed, StreamReady is now used (as you see in the posted code), StreamComplete i thinks thats never are called because is an online stream and never ends, don't know about the others events:

StreamError (ErrorCode As String, ExtraData As Int)
StreamBuffer(Percentage As Int)

Im triy today the events and see whats happen.

Really don't understand why stops play, if i use the website (with browser) the radio never stop, with the app as i can say in 20/30 minutes stops play šŸ˜¬
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
Im downloaded ExoPlayer examples from the link provided and also additional libraries and put then in the shared libs, but is imposibble to work with that because added libraries not show in B4A and i think thats because XML's files doesnĀ“t exists.
did you forget to download exoplayer.zip (containing library and xml)? from the exoplayer-thread? At the bottom of the thread are two download. An example, the Library. And a link to the additional files which should be placed in additionallibs folder.
In fact three files to download.
 
Upvote 0

Juanet

Member
Licensed User
Longtime User
DonManfred,

Sorry, my mistake, now i'm see the ExoPlayer in B4A šŸ˜¬

I'm going to try to work with ExoPlayer by changing the existing MediaPlayerStream references and see if the stream doesn't stop, thank you very much.
 
Upvote 0
Top