Search in sources :

Example 1 with StreamMediaFileOperation

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();
}
Also used : User(com.nextcloud.client.account.User) RemoteOperationResult(com.owncloud.android.lib.common.operations.RemoteOperationResult) Intent(android.content.Intent) Uri(android.net.Uri) StreamMediaFileOperation(com.owncloud.android.files.StreamMediaFileOperation)

Aggregations

Intent (android.content.Intent)1 Uri (android.net.Uri)1 User (com.nextcloud.client.account.User)1 StreamMediaFileOperation (com.owncloud.android.files.StreamMediaFileOperation)1 RemoteOperationResult (com.owncloud.android.lib.common.operations.RemoteOperationResult)1