Hi all,
I am trying to play an HLS .m3u8 stream in my B4A app with ExoPlayer.
The issue is:
I am trying to play an HLS .m3u8 stream in my B4A app with ExoPlayer.
The issue is:
- In the browser the same .m3u8 plays continuously (about 1 hour).
- In ExoPlayer it plays only one .ts segment (about 7 seconds) and then stops.
- Dim jo As JavaObject = player.CreateHLSSource(url) not work throw exception in this line -> r.Target = r.GetField("dataSourceFactory")
- Dim jo As JavaObject = player.CreateUriSource(url) this work if i replace index.m3u8 with "segment-1-v1-a1.ts?"
- original link is "https://stream.foupix.com/arabictoo...46fc11d8&ips=726247104fbed5dc850864993a7a0c4d" not play
- modify link is "https://stream.foupix.com/arabictoo...46fc11d8&ips=726247104fbed5dc850864993a7a0c4d" play one segment then stop
- Here’s the code I am using:
-
B4X:
Sub PlayM3U8(url As String) player.Initialize("player") ' Dim jo As JavaObject = player.CreateHLSSource(url) not work throw exception Dim jo As JavaObject = player.CreateUriSource(url) ' work if r.Target = r.GetField("dataSourceFactory") Dim r As Reflector r.Target = jo r.Target = r.GetField("dataSourceFactory") Dim http As JavaObject = r.GetField("baseDataSourceFactory") http.RunMethod("setDefaultRequestProperties", Array(CreateMap("Host": "www.arabic-toons.com"))) http.RunMethod("setDefaultRequestProperties", Array(CreateMap("Referer": "https://www.arabic-toons.com/"))) http.RunMethod("setDefaultRequestProperties", Array(CreateMap("Origin": "https://www.arabic-toons.com"))) http.RunMethod("setDefaultRequestProperties", Array(CreateMap("User-Agent":"Mozilla/5.0"))) http.RunMethod("setDefaultRequestProperties", Array(CreateMap("Accept":"*/*"))) http.RunMethod("setDefaultRequestProperties", Array(CreateMap("Connection":"keep-alive"))) ' http.RunMethod("setDefaultRequestProperties", Array(CreateMap("Cookie":"PHPSESSID=csa5s55eq1rticdcs42q3ad5u2"))) http.RunMethod("setDefaultRequestProperties", Array(CreateMap("Upgrade-Insecure-Requests":"1"))) http.RunMethod("setDefaultRequestProperties", Array(CreateMap("Sec-Fetch-Dest":"document"))) http.RunMethod("setDefaultRequestProperties", Array(CreateMap("Sec-Fetch-Mode":"navigate"))) http.RunMethod("setDefaultRequestProperties", Array(CreateMap("Sec-Fetch-Site":"none"))) http.RunMethod("setDefaultRequestProperties", Array(CreateMap("Sec-Fetch-User":"?1"))) Log(jo) player.Prepare(jo) SimpleExoPlayerView1.Player=player player.Play End Sub