// This updates the time bar display (if necessary). It is called by
  // mProgressChecker and also from places where the time bar needs
  // to be updated immediately.
  private int setProgress() {
    mVideoPosition = mVideoView.getCurrentPosition();
    // If the video position is smaller than the starting point of trimming,
    // correct it.
    if (mVideoPosition < mTrimStartTime) {
      mVideoView.seekTo(mTrimStartTime);
      mVideoPosition = mTrimStartTime;
    }
    // If the position is bigger than the end point of trimming, show the
    // replay button and pause.
    if (mVideoPosition >= mTrimEndTime && mTrimEndTime > 0) {
      if (mVideoPosition > mTrimEndTime) {
        mVideoView.seekTo(mTrimEndTime);
        mVideoPosition = mTrimEndTime;
      }
      mController.showEnded();
      mVideoView.pause();
    }

    int duration = mVideoView.getDuration();
    if (duration > 0 && mTrimEndTime == 0) {
      mTrimEndTime = duration;
    }
    mController.setTimes(mVideoPosition, duration, mTrimStartTime, mTrimEndTime);
    // Enable save if there's modifications
    mSaveVideoTextView.setEnabled(isModified());
    return mVideoPosition;
  }
 @Override
 public void onSeekEnd(int time, int start, int end) {
   mVideoView.seekTo(time);
   mTrimStartTime = start;
   mTrimEndTime = end;
   setProgress();
 }
Пример #3
0
        @Override
        public void onReceive(final Context context, final Intent intent) {

          if (intent.getAction().equals(VideoConst.SEND_HOSTDP_TO_VIDEOPLAYER)) {
            String mVideoAction = intent.getStringExtra(VideoConst.EXTRA_NAME);

            if (mVideoAction.equals(VideoConst.EXTRA_VALUE_VIDEO_PLAYER_PLAY)) {

              mVideoView.start();
            } else if (mVideoAction.equals(VideoConst.EXTRA_VALUE_VIDEO_PLAYER_STOP)) {
              mVideoView.stopPlayback();
              finish();
            } else if (mVideoAction.equals(VideoConst.EXTRA_VALUE_VIDEO_PLAYER_PAUSE)) {

              mVideoView.pause();
            } else if (mVideoAction.equals(VideoConst.EXTRA_VALUE_VIDEO_PLAYER_RESUME)) {

              mVideoView.resume();
              mVideoView.start();
            } else if (mVideoAction.equals(VideoConst.EXTRA_VALUE_VIDEO_PLAYER_SEEK)) {
              int pos = intent.getIntExtra("pos", -1);
              mVideoView.seekTo(pos);
            }
          }
        }
 @Override
 public void onResume() {
   super.onResume();
   if (mHasPaused) {
     mVideoView.seekTo(mVideoPosition);
     mVideoView.resume();
     mHasPaused = false;
   }
   mHandler.post(mProgressChecker);
 }
 void syncVideo() {
   VideoView view = (VideoView) findViewById(R.id.videoView1);
   Time time = new Time();
   time.setToNow();
   current = time.hour / 6;
   int offset = ((time.hour % 6) * 3600000) + (time.minute * 60000) + (time.second * 1000);
   view.setVideoURI(uris.get(current));
   view.seekTo(offset);
   view.start();
 }
Пример #6
0
 public void seekVideo(int seekTo) {
   if (mVideoView != null) {
     if (seekTo > 0) {
       if (LOCAL_LOGV) {
         Log.v(TAG, "Seeking video playback to " + seekTo);
       }
       mVideoView.seekTo(seekTo);
     }
   }
 }
Пример #7
0
  @Override
  protected void onResume() {
    super.onResume();

    try {
      videoView.seekTo(progress);
      videoView.start();
    } catch (Exception e) {
    }
  }
Пример #8
0
  private void showPreview(int position) {
    if (mMediaInfo.getUri() == null || mMediaInfo.getUri().getString().isEmpty()) {
      return;
    }

    int seekTo = percentToPosition(position);

    mVideoPosition = seekTo / 1000;

    mVideoView.seekTo((int) mVideoPosition);
  }
 @Override
 protected void onResume() {
   super.onResume();
   if (state_onpause == true) {
     VideoPlayer.setVideoURI(Uri.parse(videoURL));
     VideoPlayer.requestFocus();
     VideoPlayer.seekTo(seekPosition);
     VideoPlayer.start();
     state_onpause = false;
   }
 }
Пример #10
0
  @Override
  protected void onResume() {
    // When resuming, VideoView needs to reinitialize its MediaPlayer with the video path
    // and therefore reset the count to zero, to let it retry on error
    mVideoRetries = 0;
    startProgressChecker();

    mVideoView.seekTo(mSeekerPositionOnPause);
    if (!mIsVideoFinishedPlaying) {
      mVideoView.start();
    }
  }
  @Override
  protected void onResume() {
    super.onResume();
    clearNotification();
    wakeLock.acquire();
    checkNote = false;

    if (resumeState == 1) {
      PG.setVisibility(View.VISIBLE);
      vRadioView.seekTo(seekPosition);
      vRadioView.start();
      resumeState = 0;
    }
  }
Пример #12
0
 // SeekBar의 드래깅
 @Override
 public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
   try {
     if (fromUser) {
       if (mStat == 0) {
         mMediaPlayer.seekTo(mPlayProgressBar.getProgress());
         mMediaPlayer.start();
       } else {
         mVideoView.seekTo(mPlayProgressBar.getProgress());
         mVideoView.start();
       }
     }
     //            Toast.makeText(getApplicationContext(), "드래깅", Toast.LENGTH_SHORT).show();
   } catch (Exception e) {
   }
 }
  /** Implementation of OnPlayPauseClickedListener */
  public void onFragmentPlayPause(Movie movie, int position, Boolean playPause) {
    mVideoView.setVideoPath(movie.getVideoUrl());

    if (position == 0 || mPlaybackState == LeanbackPlaybackState.IDLE) {
      setupCallbacks();
      mPlaybackState = LeanbackPlaybackState.IDLE;
    }

    if (playPause && mPlaybackState != LeanbackPlaybackState.PLAYING) {
      mPlaybackState = LeanbackPlaybackState.PLAYING;
      if (position > 0) {
        mVideoView.seekTo(position);
        mVideoView.start();
      }
    } else {
      mPlaybackState = LeanbackPlaybackState.PAUSED;
      mVideoView.pause();
    }
    updatePlaybackState(position);
    updateMetadata(movie);
  }
 @Override
 public void onSeekMove(int time) {
   mVideoView.seekTo(time);
 }
Пример #15
0
 public void updateView() {
   if (mVideoView != null && mMediaInfo.getUri() != null) {
     int position = (int) mVideoPosition;
     mVideoView.seekTo(position);
   }
 }
Пример #16
0
 @Override
 public void onResume() {
   super.onResume();
   myVideoView.seekTo(position);
   myVideoView.start();
 }
 @Override
 public void onReplay() {
   mVideoView.seekTo(mTrimStartTime);
   playVideo();
 }
Пример #18
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_plot);
    String vidPath = getIntent().getStringExtra("vidPath");
    scale = getIntent().getDoubleExtra("Scale", 0);
    String timeTest = String.valueOf(scale);
    Log.d("MyTag4", timeTest);
    // Initializing videoView to link this java activity to the .xml layout.
    myVideoView = (VideoView) findViewById(R.id.plot_video);
    // Uniform Resource Identifier(Uri) is used as an address to identify things
    myVideoView.setVideoURI(Uri.parse(vidPath));
    // Initializing the MediaController for the video to be played.
    // myMediaController = new MediaController(this);
    // myVideoView.setMediaController(myMediaController);
    // These listeners help to get information about the videoview player
    // Completion listeners can be used to explaning when video is done, and what to do.
    myVideoView.setOnCompletionListener(myVideoViewCompletionListener);
    // Used to display time of still image from frame.
    myVideoView.setOnPreparedListener(MyVideoViewPreparedListener);
    // Used to display is any errors went on when video started or was playing.
    myVideoView.setOnErrorListener(myVideoViewErrorListener);
    // Sets focus on the widget
    myVideoView.requestFocus();
    TextView runTime = (TextView) findViewById(R.id.time_text);
    runTime.setText(Integer.toString(myVideoView.getCurrentPosition()) + " (ms)");
    myVideoView.seekTo(count);
    // Initialize seekbutton to be used to go frame-by-frame in video.
    ImageButton buttonFwdSeek = (ImageButton) findViewById(R.id.seek_fwd);
    // Set's OnClickListener to know when the button had been clicked, then executes the code.
    buttonFwdSeek.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View view) {
            /*Gets the current position of video and makes sure its always less than the total
            duration of the video so it doesn't over play.*/
            if (myVideoView.getCurrentPosition() < myVideoView.getDuration()) {
              // Keeps a count and seeks video to specified frame..
              // Which is 1/10 of a sec or 100 milliseconds.
              currentTime = count;
              //
              count = myVideoView.getCurrentPosition() + 250;
              TextView runTime = (TextView) findViewById(R.id.time_text);
              runTime.setText(Integer.toString(myVideoView.getCurrentPosition()) + " (ms)");
              myVideoView.seekTo(count);
              // dnum = dnum + 33.33;
              // count = (int)Math.round(dnum);

            }
          }
        });
    ImageButton buttonBackSeek = (ImageButton) findViewById(R.id.seek_back);
    buttonBackSeek.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View view) {
            if (myVideoView.getCurrentPosition() >= 0) {
              count = myVideoView.getCurrentPosition() - 250;
              //
              currentTime = count;
              myVideoView.seekTo(count);
              TextView runTime = (TextView) findViewById(R.id.time_text);
              runTime.setText(Integer.toString(myVideoView.getCurrentPosition()) + " (ms)");
            }
          }
        });
    ImageButton backButton = (ImageButton) findViewById(R.id.back_button);
    backButton.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View view) {
            if (myVideoView.getCurrentPosition() >= 0) {
              count = myVideoView.getCurrentPosition() - 1000;
              //
              currentTime = count;
              myVideoView.seekTo(count);
              TextView runTime = (TextView) findViewById(R.id.time_text);
              runTime.setText(Integer.toString(myVideoView.getCurrentPosition()) + " (ms)");
            }
          }
        });
    ImageButton fwdButton = (ImageButton) findViewById(R.id.fwd_button);
    fwdButton.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View view) {
            if (myVideoView.getCurrentPosition() < myVideoView.getDuration()) {
              // Keeps a count and seeks video to specified frame.Which is 1 sec, let's user get
              // through video faster.
              currentTime = count;
              myVideoView.seekTo(count);
              count = myVideoView.getCurrentPosition() + 1000;
              TextView runTime = (TextView) findViewById(R.id.time_text);
              runTime.setText(Integer.toString(myVideoView.getCurrentPosition()) + " (ms)");
            }
          }
        });
    // Intent that restarts the current activity.
    ImageButton deleteButton = (ImageButton) findViewById(R.id.delete_button);
    deleteButton.setOnClickListener(
        new View.OnClickListener() {
          public void onClick(View view) {
            Intent intent = getIntent();
            finish();
            startActivity(intent);
          }
        });

    ImageButton graphButton = (ImageButton) findViewById(R.id.graph_button);
    graphButton.setOnClickListener(
        new View.OnClickListener() {
          public void onClick(View view) {
            if (clickCount >= 3) {
              double tPoints[] = new double[time.size()];
              for (int i = 0; i < time.size(); i++) {
                tPoints[i] = time.get(i);
              }
              double xPoints[] = new double[xTap.size()];
              for (int i = 0; i < xTap.size(); i++) {
                xPoints[i] = xTap.get(i);
              }

              Intent graphIntent = new Intent(getApplicationContext(), GraphingActivity.class);
              graphIntent.putExtra("tPoints", tPoints);
              graphIntent.putExtra("xPoints", xPoints);
              startActivity(graphIntent);
            } else {
              Toast.makeText(PlotActivity.this, "plot more points", Toast.LENGTH_SHORT).show();
            }
          }
        });
    View buttonView = (View) findViewById(R.id.plot_buttons);
    buttonView.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {}
        });
  }