我正在使用vitamio库在安卓系统中播放视频流。虽然我可以用它播放rtsp streaming,但我不能播放udp streaming。
我通过gradle集成了vitamio
compile 'me.neavo:vitamio:4.2.2'并在下面这样的活动中使用它
setContentView(R.layout.activity_main);
if (!io.vov.vitamio.LibsChecker.checkVitamioLibs(this)) //it will check the include library of Vitamio
return;
mVideoView = (VideoView) findViewById(R.id.videoView);
Vitamio.initialize(this);
mVideoView.setVideoPath("udp://@192.168.0.104:1234");
//mVideoView.setVideoPath("rtsp://192.168.0.104:8554/ss");
mVideoView.setVideoQuality(MediaPlayer.VIDEOQUALITY_HIGH);
mVideoView.setBufferSize(2048);
mVideoView.requestFocus();
mVideoView.start();
mVideoView.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
@Override
public void onPrepared(MediaPlayer mediaPlayer) {
mediaPlayer.setPlaybackSpeed(1.0f);
}
});
mVideoView.setOnErrorListener(new MediaPlayer.OnErrorListener() {
@Override
public boolean onError(MediaPlayer mp, int what, int extra) {
return false;
}
});以下是我的布局代码
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="me.example.vitamiotest.MainActivity">
<io.vov.vitamio.widget.VideoView
android:layout_width="0dp"
android:layout_height="0dp"
android:id="@+id/videoView"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</android.support.constraint.ConstraintLayout>我试着将url改成udp://@192.168.0.104:1234 (删除@),但没有成功。rtsp流播放得很好。
这里有一件事需要注意,这些流实际上并不是某个远程url中的实况流。我正在使用vlc和192.168.0.104从我的PC流式传输是我的PC的本地ip .In情况下的rtsp我可以播放rtsp://192.168.0.104:8554/ss这个网址,但对于udp没有工作,没有错误消息在日志中。
发布于 2017-12-07 12:09:23
在你的电脑上试试这个udp流,或者使用其他SoftWare;在我的应用程序中,udp steam播放正常。
mVideoView.setVideoPath("udp://@238.0.0.1:1234");
https://stackoverflow.com/questions/45521175
复制相似问题