首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >VideoView RTMP的Vitamio问题

VideoView RTMP的Vitamio问题
EN

Stack Overflow用户
提问于 2018-03-06 10:27:04
回答 1查看 327关注 0票数 0

我正在尝试将RTMP中的实时视频流式传输到我的Android应用程序中。这是我到目前为止的代码:

代码语言:javascript
复制
import io.vov.vitamio.widget.VideoView;

public class LiveActivity extends AppCompatActivity {

    private int responselive;
    private int responsetoggle;
    private String frontlivefeed;
    private String backlivefeed;
    private String toggled = "";
    private boolean enableFront = true;
    private boolean enableBack = true;

    private Button fronttoggle;
    private Button backtoggle;
    private VideoView frontvehicle;
    private VideoView backvehicle;

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

        fronttoggle = (Button) findViewById(R.id.fronttoggleButton);
        backtoggle = (Button) findViewById(R.id.backtoggleButton);
        frontvehicle = (VideoView) findViewById(R.id.frontvideoView);
        backvehicle = (VideoView) findViewById(R.id.backvideoView);

        try
        {
            String templive = "https://archive.org/download/ksnn_compilation_master_the_internet/ksnn_compilation_master_the_internet_512kb.mp4";
            String frontlive = "rtmp://18.217.120.158/test/a";
            String backlive = "rtmp://18.217.120.158/test/a";
            final Uri fronturi = Uri.parse(frontlive);
            final Uri backuri = Uri.parse(backlive);

            if(fronturi == null)
            {
                Toast.makeText(LiveActivity.this, "Front connection is null", Toast.LENGTH_SHORT).show();
            }

            else
            {
                frontvehicle.setVideoURI(fronturi);
                frontvehicle.requestFocus();
                frontvehicle.start();

                fronttoggle.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View view)
                    {
                        if (frontvehicle.isPlaying())
                        {
                            frontvehicle.stopPlayback();
                        }
                        else
                        {
                            frontvehicle.setVideoURI(fronturi);
                            frontvehicle.requestFocus();
                            frontvehicle.start();
                        }
                    }
                });
            }

            if(backuri == null)
            {
                Toast.makeText(LiveActivity.this, "Back connection is null", Toast.LENGTH_SHORT).show();
            }

            else
            {
                backvehicle.setVideoURI(backuri);
                backvehicle.requestFocus();
                backvehicle.start();
            }

            backtoggle.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    if(backvehicle.isPlaying())
                    {
                        backvehicle.stopPlayback();
                    }

                    else
                    {
                        backvehicle.setVideoURI(backuri);
                        backvehicle.requestFocus();
                        backvehicle.start();
                    }
                }
            });
        }

        catch (Exception e)
        {
            Toast.makeText(LiveActivity.this, "Error connecting", Toast.LENGTH_SHORT).show();
            e.printStackTrace();
        }

        // Leave this comments for now until API is set.
        /*
        new getLiveFeed().execute(((userInfo) getApplication()).gethttp() + "/device/live/feed");
        */
    }

我得到了这些错误:

代码语言:javascript
复制
Error loading libs
    java.lang.UnsatisfiedLinkError: Expecting an absolute path of the library: libstlport_shared.so
    java.lang.UnsatisfiedLinkError: No implementation found for void io.vov.vitamio.MediaPlayer.native_init() (tried Java_io_vov_vitamio_MediaPlayer_native_1init and Java_io_vov_vitamio_MediaPlayer_native_1init__)
    at io.vov.vitamio.MediaPlayer.native_init(Native Method)

有人知道我如何解决这些问题吗?或者有没有其他方法可以将直播视频流式传输到我的Android应用程序中?

EN

回答 1

Stack Overflow用户

发布于 2018-03-06 11:08:41

您必须首先通过调用此LibsChecker.checkVitamioLibs(this)来加载native library

这是我从演示应用中得到的:

代码语言:javascript
复制
public class VideoViewDemo extends Activity {

private String path = "udp://236.1.0.1:2000";
private VideoView mVideoView;

@Override
public void onCreate(Bundle icicle) {
    super.onCreate(icicle);
    if (!LibsChecker.checkVitamioLibs(this))
        return;
    setContentView(R.layout.videoview);
    mVideoView = (VideoView) findViewById(R.id.surface_view);

    if (path == "") {
        // Tell the user to provide a media file URL/path.
        Toast.makeText(VideoViewDemo.this, "Please edit VideoViewDemo Activity, and set path" + " variable to your media file URL/path", Toast.LENGTH_LONG).show();
        return;
    } else {
        mVideoView.setVideoURI(Uri.parse(path));
        mVideoView.setMediaController(new MediaController(this));
        mVideoView.requestFocus();

    }
}
}
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/49122491

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档