Skip to content Skip to sidebar Skip to footer

Android: Is There A Way To Stream Video On A App?

I've seen apps like netflix that stream video. Is there a way to do this using the sdk? I could not find anything about how to stream on android.

Solution 1:

Here a simple example of a VideoView streaming a file

public class VideoPlayer extends Activity {

String url = "http://yourvideo/url/video.mp4";

   @Override
   public void onCreate(Bundle savedInstanceState) {
       super.onCreate(savedInstanceState);
       setContentView(R.layout.main);
       VideoView myVideoView = (VideoView)findViewById(R.id.myvideoview);
       myVideoView.setVideoURI(Uri.parse(url));
       myVideoView.setMediaController(new MediaController(this));
       myVideoView.requestFocus();
       myVideoView.start();
   }
}

And in your XML somewhere:

<VideoView
   android:id="@+id/myvideoview"
   android:layout_width="fill_parent"
   android:layout_height="wrap_content" />

Post a Comment for "Android: Is There A Way To Stream Video On A App?"