private void applyResult(int resultCode) { vPlayerHandler.removeMessages(BUFFER_PROGRESS); Intent i = new Intent(); i.putExtra("filePath", mUri.toString()); if (isInitialized()) { i.putExtra("position", (double) vPlayer.getCurrentPosition() / vPlayer.getDuration()); i.putExtra("duration", vPlayer.getDuration()); savePosition(); } switch (resultCode) { case RESULT_FAILED: if (toast != null) { toast.setText(R.string.video_cannot_play); toast.setDuration(Toast.LENGTH_SHORT); toast.show(); } else { toast = Toast.makeText(this, R.string.video_cannot_play, Toast.LENGTH_SHORT); toast.show(); } break; case RESULT_CANCELED: case RESULT_OK: break; } setResult(resultCode, i); }
@Override public long getCurrentPosition() { if (isInitialized()) return vPlayer.getCurrentPosition(); return (long) (getStartPosition() * vPlayer.getDuration()); }
private void savePosition() { if (vPlayer != null && mUri != null) { if (mEnd) lastposition = 1.0f; else lastposition = (float) (vPlayer.getCurrentPosition() / (double) vPlayer.getDuration()); } }