Advertisement
Guest User

activity

a guest
Jun 6th, 2015
21
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.98 KB | None | 0 0
  1. package pl.klonica.imafreak.supernanny;
  2.  
  3. import android.app.Activity;
  4. import android.os.Bundle;
  5. import android.text.TextUtils;
  6. import android.view.View;
  7. import android.widget.Toast;
  8.  
  9. import io.vov.vitamio.LibsChecker;
  10. import io.vov.vitamio.MediaPlayer;
  11. import io.vov.vitamio.widget.MediaController;
  12. import io.vov.vitamio.widget.VideoView;
  13.  
  14. public class VideoCaptureActivity extends Activity {
  15.  
  16.     private String pathToFileOrUrl= "http://192.168.0.102:8989/";
  17.     private VideoView mVideoView;
  18.  
  19.     @Override
  20.     public void onCreate(Bundle icicle) {
  21.         super.onCreate(icicle);
  22.  
  23.         if (!LibsChecker.checkVitamioLibs(this))
  24.             return;
  25.  
  26.         setContentView(R.layout.activity_video_capture);
  27.         mVideoView = (VideoView) findViewById(R.id.surface_view);
  28.  
  29.         if (pathToFileOrUrl == "") {
  30.             Toast.makeText(this, "Please set the video path for your media file", Toast.LENGTH_LONG).show();
  31.             return;
  32.         } else {
  33.  
  34.             /*
  35.              * Alternatively,for streaming media you can use
  36.              * mVideoView.setVideoURI(Uri.parse(URLstring));
  37.              */
  38.             mVideoView.setVideoPath(pathToFileOrUrl);
  39.             mVideoView.setMediaController(new MediaController(this));
  40.             mVideoView.requestFocus();
  41.             mVideoView.setBufferSize(512);
  42.  
  43.             mVideoView.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
  44.                 @Override
  45.                 public void onPrepared(MediaPlayer mediaPlayer) {
  46.                     // optional need Vitamio 4.0
  47.                     mediaPlayer.setPlaybackSpeed(1.25f);
  48.                     mediaPlayer.setBufferSize(512);
  49.                 }
  50.             });
  51.         }
  52.  
  53.     }
  54.  
  55.     public void startPlay(View view) {
  56.         if (!TextUtils.isEmpty(pathToFileOrUrl)) {
  57.             mVideoView.setVideoPath(pathToFileOrUrl);
  58.         }
  59.     }
  60.  
  61.     public void openVideo(View View) {
  62.         mVideoView.setVideoPath(pathToFileOrUrl);
  63.     }
  64.  
  65. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement