Simple Stream Player for Android


SUBMITTED BY: Guest

DATE: Feb. 4, 2015, 1:14 a.m.

FORMAT: Java

SIZE: 1.2 kB

HITS: 617

  1. package your.package.name;
  2. //we will need this stuff...
  3. import android.app.Activity;
  4. import android.os.Bundle;
  5. import android.net.Uri;
  6. import android.view.WindowManager;
  7. import android.widget.MediaController;
  8. import android.widget.VideoView;
  9. public class YourActivityName extends Activity {
  10. @Override
  11. protected void onCreate(Bundle savedInstanceState) {
  12. super.onCreate(savedInstanceState);
  13. setContentView(R.layout.player_layout); //You need the layout defined, check the last part of the paste
  14. getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); //This is to keep the screen on
  15. VideoView vPlayer = (VideoView)findViewById(R.id.videoPlayer);
  16. Uri vUri = Uri.parse("https://..."); //Put your URL here
  17. vPlayer.setVideoURI(vUri);
  18. MediaController vControl = new MediaController(this); //Now we will attach some buttons to control the playback
  19. vControl.setAnchorView(vPlayer);
  20. vPlayer.setMediaController(vControl);
  21. vPlayer.start(); //And that's it... Play the file :)
  22. }
  23. }
  24. XML layout needed to run this paste: http://bitbin.it/d76ZWU1q

comments powered by Disqus