package com.owncloud.android.ui.preview;
+import com.owncloud.android.R;
+import com.owncloud.android.datamodel.OCFile;
+import com.owncloud.android.media.MediaService;
+import com.owncloud.android.ui.activity.FileActivity;
+
import android.accounts.Account;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.widget.MediaController;
import android.widget.VideoView;
-import com.owncloud.android.AccountUtils;
-import com.owncloud.android.Log_OC;
-import com.owncloud.android.R;
-import com.owncloud.android.datamodel.DataStorageManager;
-import com.owncloud.android.datamodel.FileDataStorageManager;
-import com.owncloud.android.datamodel.OCFile;
-import com.owncloud.android.media.MediaService;
-import com.owncloud.android.ui.activity.FileActivity;
+import com.owncloud.android.lib.common.accounts.AccountUtils;
+import com.owncloud.android.lib.common.accounts.AccountUtils.AccountNotFoundException;
+import com.owncloud.android.lib.common.utils.Log_OC;
/**
* Activity implementing a basic video player.
private static final String TAG = PreviewVideoActivity.class.getSimpleName();
- private DataStorageManager mStorageManager;
-
private int mSavedPlaybackPosition; // in the unit time handled by MediaPlayer.getCurrentPosition()
private boolean mAutoplay; // when 'true', the playback starts immediately with the activity
private VideoView mVideoPlayer; // view to play the file; both performs and show the playback
return true;
}
-
@Override
protected void onAccountSet(boolean stateWasRecovered) {
+ super.onAccountSet(stateWasRecovered);
if (getAccount() != null) {
OCFile file = getFile();
/// Validate handled file (first image to preview)
if (!file.isVideo()) {
throw new IllegalArgumentException("Non-video file passed as argument");
}
- mStorageManager = new FileDataStorageManager(getAccount(), getContentResolver());
- file = mStorageManager.getFileById(file.getFileId());
+ file = getStorageManager().getFileById(file.getFileId());
if (file != null) {
if (file.isDown()) {
mVideoPlayer.setVideoPath(file.getStoragePath());
} else {
- // not working now
- String url = AccountUtils.constructFullURLForAccount(this, getAccount()) + file.getRemotePath();
- mVideoPlayer.setVideoURI(Uri.parse(url));
+ // not working yet
+ String url;
+ try {
+ url = AccountUtils.constructFullURLForAccount(this, getAccount()) + file.getRemotePath();
+ mVideoPlayer.setVideoURI(Uri.parse(url));
+ } catch (AccountNotFoundException e) {
+ onError(null, MediaService.OC_MEDIA_ERROR, R.string.media_err_no_account);
+ }
}
// create and prepare control panel for the user
finish();
}
} else {
- Log_OC.wtf(TAG, "onAccountChanged was called with NULL account associated!");
finish();
}
}