I am trying to stream live video in the from of RTMP to my Android app. This is my code so far:
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");
*/
}
And I am getting these errors:
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)
Does anyone know how I can resolve them or is there an alternative method to stream live video to my Android app?
You have to load
native libraryfirst by calling thisLibsChecker.checkVitamioLibs(this).This is what I got from demo app: