I am working on an Android app which can stream videos from a NodeJS server.
I am new to video streaming. I first added a VideoView in an Android application as the following:
VideoView mVidView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mVidView = (VideoView)findViewById(R.id.myVideo);
MediaController mediaCtrl = new MediaController(this);
mediaCtrl.setAnchorView(mVidView);
String vidAddress = "http://ift.tt/1Ab30Jw";
Uri video = Uri.parse(vidAddress);
mVidView.setVideoURI(video);
mVidView.setMediaController(mediaCtrl);
mVidView.start();
}
It works well on Android Emulator. The video from the given url is being played and media controller can be used.
Next, I build a NodeJS http server and added a mp4 file(moviesample1.mp4) to the server. I then changed the vidAddress to:
String vidAddress = "http://ift.tt/1wl5f0z";
where 10.0.2.2 is the ip of the build machine and 1337 is the port.
When I type the url above in a browser(e.g. Chrome), the movie is played within the browser. However, when I run the android app in emulator, the app shows a dialog which says "Can't play this video".
I realize that I may not have video streaming enabled on my NodeJS http server. I then searched for NodeJS streaming packages, such as vid-streamer(http://ift.tt/1wl5f0D)
I successfully installed vid-streamer and run an instance of a http server with it. I can see the movie within browser. However, when I change vidAddress in the android app to "http://ift.tt/1Ab32RF" while keeping the vid-streamer server running, the result is the same, "Can't play this video".
What should I do?
Aucun commentaire:
Enregistrer un commentaire