use of com.owncloud.android.files.StreamMediaFileOperation in project android by nextcloud.
the class FileOperationsHelper method streamMediaFile.
public void streamMediaFile(OCFile file) {
fileActivity.showLoadingDialog(fileActivity.getString(R.string.wait_a_moment));
final User user = currentAccount.getUser();
new Thread(() -> {
StreamMediaFileOperation sfo = new StreamMediaFileOperation(file.getRemoteId());
RemoteOperationResult result = sfo.execute(user.toPlatformAccount(), fileActivity);
fileActivity.dismissLoadingDialog();
if (!result.isSuccess()) {
DisplayUtils.showSnackMessage(fileActivity, R.string.stream_not_possible_headline);
return;
}
Intent openFileWithIntent = new Intent(Intent.ACTION_VIEW);
Uri uri = Uri.parse((String) result.getData().get(0));
openFileWithIntent.setDataAndType(uri, file.getMimeType());
fileActivity.startActivity(Intent.createChooser(openFileWithIntent, fileActivity.getString(R.string.stream)));
}).start();
}
Aggregations