gpt4 book ai didi

java - UDP 流无法在 ExoPlayer 上播放

转载 作者:行者123 更新时间:2023-11-30 06:13:59 24 4
gpt4 key购买 nike

我是 Exoplayer udp 流媒体新手。我已经在 HTTP 实时流媒体上做了一些工作,但没有在 udp 上完成。现在尝试在 exoplayer 上播放 udp 流,用 google 搜索了很多,但没有运气。

请查看以下 logcat。

如有任何帮助,我们将不胜感激。

04-03 21:33:45.376 31547-31827/com.chernowii.udp_stream_android E/ExoPlayerImplInternal: Source error.
com.google.android.exoplayer2.upstream.HttpDataSource$HttpDataSourceException: Unable to connect to udp://@x.x.x.x:xxxx
at com.google.android.exoplayer2.upstream.DefaultHttpDataSource.open(DefaultHttpDataSource.java:194)
at com.google.android.exoplayer2.upstream.DefaultDataSource.open(DefaultDataSource.java:137)
at com.google.android.exoplayer2.source.ExtractorMediaPeriod$ExtractingLoadable.load(ExtractorMediaPeriod.java:692)
at com.google.android.exoplayer2.upstream.Loader$LoadTask.run(Loader.java:315)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
at java.lang.Thread.run(Thread.java:762)
Caused by: java.net.MalformedURLException: unknown protocol: udp
at java.net.URL.<init>(URL.java:596)
at java.net.URL.<init>(URL.java:486)
at java.net.URL.<init>(URL.java:435)
at com.google.android.exoplayer2.upstream.DefaultHttpDataSource.makeConnection(DefaultHttpDataSource.java:341)
at com.google.android.exoplayer2.upstream.DefaultHttpDataSource.open(DefaultHttpDataSource.java:192)
at com.google.android.exoplayer2.upstream.DefaultDataSource.open(DefaultDataSource.java:137) 
at com.google.android.exoplayer2.source.ExtractorMediaPeriod$ExtractingLoadable.load(ExtractorMediaPeriod.java:692) 
at com.google.android.exoplayer2.upstream.Loader$LoadTask.run(Loader.java:315) 
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133) 
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607) 
at java.lang.Thread.run(Thread.java:762) 
04-03 21:33:45.377 31547-31547/com.chernowii.udp_stream_android V/ExoPlayer GP Demo: Listener-onPlayerError...
04-03 21:33:45.378 31547-31547/com.chernowii.udp_stream_android V/ExoPlayer GP Demo: Listener-onTimelineChanged...
Listener-onLoadingChanged...isLoading:false
04-03 21:33:45.379 31547-31547/com.chernowii.udp_stream_android V/ExoPlayer GP Demo: Listener-onPlayerStateChanged...1
04-03 21:33:45.395 31547-31547/com.chernowii.udp_stream_android V/ExoPlayer GP Demo: Listener-onPlayerStateChanged...2
04-03 21:33:45.396 31547-31547/com.chernowii.udp_stream_android V/ExoPlayer GP Demo: Listener-onTimelineChanged...
Listener-onLoadingChanged...isLoading:true
04-03 21:33:48.406 31547-31827/com.chernowii.udp_stream_android E/ExoPlayerImplInternal: Source error.
com.google.android.exoplayer2.upstream.HttpDataSource$HttpDataSourceException: Unable to connect to udp://@224.2.2.1:3000
at com.google.android.exoplayer2.upstream.DefaultHttpDataSource.open(DefaultHttpDataSource.java:194)
at com.google.android.exoplayer2.upstream.DefaultDataSource.open(DefaultDataSource.java:137)
at com.google.android.exoplayer2.source.ExtractorMediaPeriod$ExtractingLoadable.load(ExtractorMediaPeriod.java:692)
at com.google.android.exoplayer2.upstream.Loader$LoadTask.run(Loader.java:315)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
at java.lang.Thread.run(Thread.java:762)
Caused by: java.net.MalformedURLException: unknown protocol: udp
at java.net.URL.<init>(URL.java:596)
at java.net.URL.<init>(URL.java:486)
at java.net.URL.<init>(URL.java:435)
at com.google.android.exoplayer2.upstream.DefaultHttpDataSource.makeConnection(DefaultHttpDataSource.java:341)
at com.google.android.exoplayer2.upstream.DefaultHttpDataSource.open(DefaultHttpDataSource.java:192)
at com.google.android.exoplayer2.upstream.DefaultDataSource.open(DefaultDataSource.java:137) 
at com.google.android.exoplayer2.source.ExtractorMediaPeriod$ExtractingLoadable.load(ExtractorMediaPeriod.java:692) 
at com.google.android.exoplayer2.upstream.Loader$LoadTask.run(Loader.java:315) 
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133) 
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607) 
at java.lang.Thread.run(Thread.java:762) 
04-03 21:33:48.419 31547-31547/com.chernowii.udp_stream_android V/ExoPlayer GP Demo: Listener-onPlayerError...
04-03 21:33:48.421 31547-31547/com.chernowii.udp_stream_android V/ExoPlayer GP Demo: Listener-onTimelineChanged...
04-03 21:33:48.422 31547-31547/com.chernowii.udp_stream_android V/ExoPlayer GP Demo: Listener-onLoadingChanged...isLoading:false
04-03 21:33:48.423 31547-31547/com.chernowii.udp_stream_android V/ExoPlayer GP Demo: Listener-onPlayerStateChanged...1
04-03 21:33:48.440 31547-31547/com.chernowii.udp_stream_android V/ExoPlayer GP Demo: Listener-onPlayerStateChanged...2
04-03 21:33:48.441 31547-31547/com.chernowii.udp_stream_android V/ExoPlayer GP Demo: Listener-onTimelineChanged...
04-03 21:33:48.442 31547-31547/com.chernowii.udp_stream_android V/ExoPlayer GP Demo: Listener-onLoadingChanged...isLoading:true

最佳答案

您需要为 Exo 创建精确的媒体源,例如

val myDataSourceFactory = DefaultDataSourceFactory(this, null, { -> UdpDataSource(this, 2000, 20000) })
// Extractor factory & media source
val extractorsFactory = DefaultExtractorsFactory()
val mediaSource = ExtractorMediaSource(uri, myDataSourceFactory, extractorsFactory, null, null)
player?.prepare(mediaSource, true, false)

关于java - UDP 流无法在 ExoPlayer 上播放,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49635150/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com