gpt4 book ai didi

android - 如何使用 exoplayer 流式传输 rtsp url?

转载 作者:塔克拉玛干 更新时间:2023-11-02 21:03:13 28 4
gpt4 key购买 nike

我想使用 exoplayer 流式传输 rtsp 视频。我正在使用 ExoMedia library这是一个 Android ExoPlayer 包装器。我在 stackoverflow 上搜索过,但没有找到任何好的答案。经过一些谷歌搜索,我发现 exoplayer 不支持 rtsp 流 issue 55 .有什么方法可以使用 exoplayer 流式传输 rtsp url 吗? 这是我的代码。

public class MainActivity extends AppCompatActivity implements OnPreparedListener{
EMVideoView emPlayer;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
playVideo();
}


private void playVideo() {
emPlayer = (EMVideoView)findViewById(R.id.video_view);
emPlayer.setOnPreparedListener(this);

emPlayer.setVideoURI(Uri.parse("rtsp://184.72.239.149/vod/mp4:BigBuckBunny_115k.mov"));
}

@Override
public void onPrepared() {
emPlayer.start();
Log.v("TAG","video is playing");
}
}

这是我的日志

com.google.android.exoplayer.ExoPlaybackException: com.google.android.exoplayer.upstream.HttpDataSource$HttpDataSourceException: Unable to connect to rtsp://184.72.239.149/vod/mp4:BigBuckBunny_115k.mov
at com.google.android.exoplayer.SampleSourceTrackRenderer.maybeThrowError(SampleSourceTrackRenderer.java:262)
at com.google.android.exoplayer.SampleSourceTrackRenderer.maybeThrowError(SampleSourceTrackRenderer.java:148)
at com.google.android.exoplayer.ExoPlayerImplInternal.incrementalPrepareInternal(ExoPlayerImplInternal.java:273)
at com.google.android.exoplayer.ExoPlayerImplInternal.handleMessage(ExoPlayerImplInternal.java:203)
at android.os.Handler.dispatchMessage(Handler.java:98)
at android.os.Looper.loop(Looper.java:135)
at android.os.HandlerThread.run(HandlerThread.java:61)
at com.google.android.exoplayer.util.PriorityHandlerThread.run(PriorityHandlerThread.java:40)
Caused by: com.google.android.exoplayer.upstream.HttpDataSource$HttpDataSourceException: Unable to connect to rtsp://184.72.239.149/vod/mp4:BigBuckBunny_115k.mov
at com.google.android.exoplayer.upstream.DefaultHttpDataSource.open(DefaultHttpDataSource.java:191)
at com.google.android.exoplayer.upstream.DefaultUriDataSource.open(DefaultUriDataSource.java:133)
at com.google.android.exoplayer.extractor.ExtractorSampleSource$ExtractingLoadable.load(ExtractorSampleSource.java:823)
at com.google.android.exoplayer.upstream.Loader$LoadTask.run(Loader.java:222)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:422)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
at java.lang.Thread.run(Thread.java:818)
Caused by: java.net.MalformedURLException: Unknown protocol: rtsp
at java.net.URL.<init>(URL.java:182)
at java.net.URL.<init>(URL.java:125)
at com.google.android.exoplayer.upstream.DefaultHttpDataSource.makeConnection(DefaultHttpDataSource.java:330)
at com.google.android.exoplayer.upstream.DefaultHttpDataSource.open(DefaultHttpDataSource.java:189)
at com.google.android.exoplayer.upstream.DefaultUriDataSource.open(DefaultUriDataSource.java:133)
at com.google.android.exoplayer.extractor.ExtractorSampleSource$ExtractingLoadable.load(ExtractorSampleSource.java:823)
at com.google.android.exoplayer.upstream.Loader$LoadTask.run(Loader.java:222)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:422)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
at java.lang.Thread.run(Thread.java:818)

最佳答案

现在 ExoPlayer 已经支持 RTSP - https://github.com/google/ExoPlayer/pull/3854

您还可以按照 rtsp 查看示例应用程序 - https://github.com/google/ExoPlayer/pull/3854#issuecomment-377010803

关于android - 如何使用 exoplayer 流式传输 rtsp url?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39717848/

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