vitamio unable to play udp streaming in android

拟墨画扇 提交于 2019-12-11 12:57:31

问题


I am using vitamio library to play video streaming in android . Though I can play rtsp streaming with it, but I can't play udp streaming .

I integrated vitamio via gradle

compile 'me.neavo:vitamio:4.2.2'

And using it on activity like following

        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;
            }
        });

Here is my code for layout

<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>

I tried chaning url to udp://@192.168.0.104:1234 (removing @) with no luck . rtsp streaming is playing well .

Here is one thing to be noted that those streaming aren't actually live streaming in some remote url . I am streaming from my PC using vlc and 192.168.0.104 is my PC's local ip .In case of rtsp I can play rtsp://192.168.0.104:8554/ss this url but for udp nothing worked, no error msg in the log .


回答1:


try this udp stream on your Pc or use other SoftWare; in my app,udp steam is playing right.

mVideoView.setVideoPath("udp://@238.0.0.1:1234");



来源:https://stackoverflow.com/questions/45521175/vitamio-unable-to-play-udp-streaming-in-android

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!