Private Sub CreateUriSource(Uri As String) As Object
Dim ctxt As JavaObject
ctxt.InitializeContext
Dim HttpDataSourceFactory As JavaObject
HttpDataSourceFactory.InitializeNewInstance("androidx.media3.datasource.DefaultHttpDataSource$Factory", Null)
HttpDataSourceFactory.RunMethod("setAllowCrossProtocolRedirects", Array(True))
Dim DataSource As JavaObject = HttpDataSourceFactory.RunMethod("createDataSource", Null)
Dim DataSourceFactory As JavaObject = ctxt.CreateEvent("androidx.media3.datasource.DataSource.Factory", "", DataSource)
Dim ProgressiveMediaSourceFactory As JavaObject...
I just realize the CreateUriSource option works.?
DefaultHttpDataSourceFactory
Urisource does work on some of the link. I came across?
DefaultHttpDataSourceFactory
Is that option available? I can't get some of the links working. Response code 302?
DefaultHttpDataSourceFactory
Post an example or the code used.Urisource does work on some of the link. I came across
Is that option available? I can't get some of the links working. Response code 302
Dim defaultHttpDataSourceFactory As JavaObject
defaultHttpDataSourceFactory.InitializeNewInstance("com.google.android.exoplayer2.upstream.DefaultHttpDataSourceFactory", _
Array(userAgent, Null, connectTimeoutMillis, readTimeoutMillis, allowCrossProtocolRedirects))
Private Sub CreateUriSource(Uri As String) As Object
Dim ctxt As JavaObject
ctxt.InitializeContext
Dim HttpDataSourceFactory As JavaObject
HttpDataSourceFactory.InitializeNewInstance("androidx.media3.datasource.DefaultHttpDataSource$Factory", Null)
HttpDataSourceFactory.RunMethod("setAllowCrossProtocolRedirects", Array(True))
Dim DataSource As JavaObject = HttpDataSourceFactory.RunMethod("createDataSource", Null)
Dim DataSourceFactory As JavaObject = ctxt.CreateEvent("androidx.media3.datasource.DataSource.Factory", "", DataSource)
Dim ProgressiveMediaSourceFactory As JavaObject
ProgressiveMediaSourceFactory.InitializeNewInstance("androidx.media3.exoplayer.source.ProgressiveMediaSource.Factory", Array(DataSourceFactory))
Dim MediaItem As JavaObject
MediaItem.InitializeStatic("androidx.media3.common.MediaItem")
Return ProgressiveMediaSourceFactory.RunMethod("createMediaSource", Array(MediaItem.RunMethod("fromUri", Array(Uri))))
End Sub
player1.Prepare(CreateUriSource("https://bestvpn.org/html5demos/assets/dizzy.mp4"))
This code will not do anything.What library do you use exoplayer2 or exoplayer3?
example exoplayer2
B4X:Dim defaultHttpDataSourceFactory As JavaObject defaultHttpDataSourceFactory.InitializeNewInstance("com.google.android.exoplayer2.upstream.DefaultHttpDataSourceFactory", _ Array(userAgent, Null, connectTimeoutMillis, readTimeoutMillis, allowCrossProtocolRedirects))
Awesome Erel!!! works like a charm.Here:
B4X:Private Sub CreateUriSource(Uri As String) As Object Dim ctxt As JavaObject ctxt.InitializeContext Dim HttpDataSourceFactory As JavaObject HttpDataSourceFactory.InitializeNewInstance("androidx.media3.datasource.DefaultHttpDataSource$Factory", Null) HttpDataSourceFactory.RunMethod("setAllowCrossProtocolRedirects", Array(True)) Dim DataSource As JavaObject = HttpDataSourceFactory.RunMethod("createDataSource", Null) Dim DataSourceFactory As JavaObject = ctxt.CreateEvent("androidx.media3.datasource.DataSource.Factory", "", DataSource) Dim ProgressiveMediaSourceFactory As JavaObject ProgressiveMediaSourceFactory.InitializeNewInstance("androidx.media3.exoplayer.source.ProgressiveMediaSource.Factory", Array(DataSourceFactory)) Dim MediaItem As JavaObject MediaItem.InitializeStatic("androidx.media3.common.MediaItem") Return ProgressiveMediaSourceFactory.RunMethod("createMediaSource", Array(MediaItem.RunMethod("fromUri", Array(Uri)))) End Sub
Usage:
B4X:player1.Prepare(CreateUriSource("https://bestvpn.org/html5demos/assets/dizzy.mp4"))
Is it a complement to this or could this method be added?Here:
B4X:Private Sub CreateUriSource(Uri As String) As Object Dim ctxt As JavaObject ctxt.InitializeContext Dim HttpDataSourceFactory As JavaObject HttpDataSourceFactory.InitializeNewInstance("androidx.media3.datasource.DefaultHttpDataSource$Factory", Null) HttpDataSourceFactory.RunMethod("setAllowCrossProtocolRedirects", Array(True)) Dim DataSource As JavaObject = HttpDataSourceFactory.RunMethod("createDataSource", Null) Dim DataSourceFactory As JavaObject = ctxt.CreateEvent("androidx.media3.datasource.DataSource.Factory", "", DataSource) Dim ProgressiveMediaSourceFactory As JavaObject ProgressiveMediaSourceFactory.InitializeNewInstance("androidx.media3.exoplayer.source.ProgressiveMediaSource.Factory", Array(DataSourceFactory)) Dim MediaItem As JavaObject MediaItem.InitializeStatic("androidx.media3.common.MediaItem") Return ProgressiveMediaSourceFactory.RunMethod("createMediaSource", Array(MediaItem.RunMethod("fromUri", Array(Uri)))) End Sub
Usage:
B4X:player1.Prepare(CreateUriSource("https://bestvpn.org/html5demos/assets/dizzy.mp4"))
Isn't the mime type set in datasource (HLS)?Here:
B4X:Private Sub CreateUriSource(Uri As String) As Object Dim ctxt As JavaObject ctxt.InitializeContext Dim HttpDataSourceFactory As JavaObject HttpDataSourceFactory.InitializeNewInstance("androidx.media3.datasource.DefaultHttpDataSource$Factory", Null) HttpDataSourceFactory.RunMethod("setAllowCrossProtocolRedirects", Array(True)) Dim DataSource As JavaObject = HttpDataSourceFactory.RunMethod("createDataSource", Null) Dim DataSourceFactory As JavaObject = ctxt.CreateEvent("androidx.media3.datasource.DataSource.Factory", "", DataSource) Dim ProgressiveMediaSourceFactory As JavaObject ProgressiveMediaSourceFactory.InitializeNewInstance("androidx.media3.exoplayer.source.ProgressiveMediaSource.Factory", Array(DataSourceFactory)) Dim MediaItem As JavaObject MediaItem.InitializeStatic("androidx.media3.common.MediaItem") Return ProgressiveMediaSourceFactory.RunMethod("createMediaSource", Array(MediaItem.RunMethod("fromUri", Array(Uri)))) End Sub
Usage:
B4X:player1.Prepare(CreateUriSource("https://bestvpn.org/html5demos/assets/dizzy.mp4"))