VideoView RTMP的Vitamio问题

问题描述 投票:0回答:1

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

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");
        */
    }

我收到这些错误:

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应用程序?

android android-studio vitamio
1个回答
0
投票

你必须先调用native library来加载LibsChecker.checkVitamioLibs(this)

这是我从演示应用程序获得的:

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

    }
}
}
© www.soinside.com 2019 - 2024. All rights reserved.