Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package pl.klonica.imafreak.supernanny;
- import android.app.Activity;
- import android.os.Bundle;
- import android.text.TextUtils;
- import android.view.View;
- import android.widget.Toast;
- import io.vov.vitamio.LibsChecker;
- import io.vov.vitamio.MediaPlayer;
- import io.vov.vitamio.widget.MediaController;
- import io.vov.vitamio.widget.VideoView;
- public class VideoCaptureActivity extends Activity {
- private String pathToFileOrUrl= "http://192.168.0.102:8989/";
- private VideoView mVideoView;
- @Override
- public void onCreate(Bundle icicle) {
- super.onCreate(icicle);
- if (!LibsChecker.checkVitamioLibs(this))
- return;
- setContentView(R.layout.activity_video_capture);
- mVideoView = (VideoView) findViewById(R.id.surface_view);
- if (pathToFileOrUrl == "") {
- Toast.makeText(this, "Please set the video path for your media file", Toast.LENGTH_LONG).show();
- return;
- } else {
- /*
- * Alternatively,for streaming media you can use
- * mVideoView.setVideoURI(Uri.parse(URLstring));
- */
- mVideoView.setVideoPath(pathToFileOrUrl);
- mVideoView.setMediaController(new MediaController(this));
- mVideoView.requestFocus();
- mVideoView.setBufferSize(512);
- mVideoView.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
- @Override
- public void onPrepared(MediaPlayer mediaPlayer) {
- // optional need Vitamio 4.0
- mediaPlayer.setPlaybackSpeed(1.25f);
- mediaPlayer.setBufferSize(512);
- }
- });
- }
- }
- public void startPlay(View view) {
- if (!TextUtils.isEmpty(pathToFileOrUrl)) {
- mVideoView.setVideoPath(pathToFileOrUrl);
- }
- }
- public void openVideo(View View) {
- mVideoView.setVideoPath(pathToFileOrUrl);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement