首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何将RTSP视频url播放到EXOPlayer中

如何将RTSP视频url播放到EXOPlayer中
EN

Stack Overflow用户
提问于 2019-11-29 17:59:06
回答 2查看 1.4K关注 0票数 0

我正在开发一个应用程序,到,我已经使用谷歌的ExoPlayer,它的工作方式很有魅力,现在我想添加即时通讯协议支持到我的应用程序中,但使用Exoplayer我无法发挥,请任何人可以帮助我这一点,如果有人有其他选择,请与我分享。

代码语言:javascript
复制
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 = true

lOG

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)

EN

回答 2

Stack Overflow用户

发布于 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上阅读。

票数 0
EN

Stack Overflow用户

发布于 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的流式传输的代码片段。

代码语言:javascript
复制
    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:

注意:我们已将同一网络中的设备连接起来!

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/59102571

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档