私はvitamioライブラリを使ってアンドロイドでビデオストリーミングを再生しています。私はrtsp
と一緒にストリーミングできますが、udp
ストリーミングは再生できません。vitamioはアンドロイドでudpストリーミングを再生できません
私はGradleの
compile 'me.neavo:vitamio:4.2.2'
vitamio経由を統合し、ここで
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>
ための私のコードで私は(udp://@192.168.0.104:1234
にURLをchaning試してみました運がない@を取り除く)。 rtspストリーミングがうまくいきます。
これらのストリーミングは、実際には一部のリモートURLでストリーミングされていないことに注意してください。私はvlc
と192.168.0.104
を使用して自分のPCからストリーミングしています。rtsp
の場合はrtsp://192.168.0.104:8554/ss
を再生できますが、udp
の場合は何も処理されず、エラーメッセージはログに記録されません。