vitamio无法在android中播放udp流 [英] vitamio unable to play udp streaming in android

查看:256
本文介绍了vitamio无法在android中播放udp流的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 vitamio 库在android中播放视频流.尽管我可以使用它播放rtsp流,但是我不能播放udp流.

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 .

我通过gradle集成了vitamio

I integrated vitamio via gradle

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>

我没有运气就尝试将网址更改为udp://@192.168.0.104:1234(删除@). rtsp流播放效果很好.

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

有一点需要注意的是,这些流实际上并不是在某个远程url中进行实时流传输.我正在使用vlc从我的PC流式传输,而192.168.0.104是我的PC的本地ip.在rtsp的情况下,我可以播放rtsp://192.168.0.104:8554/ss这个URL,但是对于udp没有任何作用,日志中没有错误msg./p>

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 .

推荐答案

在您的PC上尝试此udp流或使用其他软件; 在我的应用中,udp Steam正在正确播放.

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

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

这篇关于vitamio无法在android中播放udp流的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆