我正在开发一个应用程序,到,我已经使用谷歌的ExoPlayer,它的工作方式很有魅力,现在我想添加即时通讯协议支持到我的应用程序中,但使用Exoplayer我无法发挥,请任何人可以帮助我这一点,如果有人有其他选择,请与我分享。
val playerView = findViewById<PlayerView>(R.id.simple_player)
playerView.player = player
val rtmpDataSourceFactory = RtmpDataSourceFactory()
val url = mVideoPath
val videoSource = ExtractorMediaSource.Factory(rtmpDataSourceFactory)
.createMediaSource(Uri.parse("rtsp://192.168.1.74/12"))
player.prepare(videoSource)
player.playWhenReady = truelOG
E/ExoPlayerImplInternal:源错误。net.butterflytv.rtmp_client.RtmpClient$RtmpIOException at net.butterflytv.rtmp_client.RtmpClient.open(RtmpClient.java:56) at com.google.android.exoplayer2.ext.rtmp.RtmpDataSource.open(RtmpDataSource.java:60) at com.google.android.exoplayer2.upstream.StatsDataSource.open(StatsDataSource.java:83) at com.google.android.exoplayer2.source.ExtractorMediaPeriod$ExtractingLoadable.load(ExtractorMediaPeriod.java:885) at com.google.android。exoplayer2.upstream.Loader$LoadTask.run(Loader.java:381) 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:761)
发布于 2020-07-01 20:21:53
似乎the regular ExoPlayer release不支持RTSP,他们仍然有一个open ticket to add RTSP support,但是有一个git branch with RTSP support。
您正在使用RtmpDataSourceFactory,您可以尝试使用RtspMediaSource.Factory。
你也可以在difference between RTMP and RTSP上阅读。
发布于 2021-08-27 19:52:19
ExoPlayer似乎已经为Rtsp流提供了一个补丁。我使用的是ExoPlayer v2.15.0,这是最新的版本,其中包含了对Rtsp流的支持。但是我们仍然无法流式传输"rtsp://192.168.0.26:554/11“这类urls。同时,VLC也能够流式传输这类urls。
下面是给定rtsp url的流式传输的代码片段。
MediaSource mediaSource =
new RtspMediaSource.Factory().setForceUseRtpTcp(true)
.createMediaSource(MediaItem.fromUri("rtsp://192.168.0.26:554/11"));使用此命令获取源代码错误。
日志: ExoPlayerImplInternal:播放错误主机无法访问导致的源错误: java.net.NoRouteToHostException: com.google.android.exoplayer2.ExoPlaybackException:
注意:我们已将同一网络中的设备连接起来!
https://stackoverflow.com/questions/59102571
复制相似问题