Skip to content

Commit

Permalink
Merge pull request #4394 from owncloud/fix/video_streaming_in_spaces
Browse files Browse the repository at this point in the history
[BUG] Can't stream video from space
  • Loading branch information
jesmrec authored Apr 30, 2024
2 parents 4c7a1e9 + 78e50dd commit bc5c42f
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 10 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ ownCloud admins and users.

* Bugfix - Removed unnecessary requests when the app is installed from scratch: [#4213](https://github.com/owncloud/android/issues/4213)
* Bugfix - "Clear data" button enabled in the app settings in device settings: [#4309](https://github.com/owncloud/android/issues/4309)
* Bugfix - Video streaming in spaces: [#4328](https://github.com/owncloud/android/issues/4328)
* Bugfix - Retried successful uploads are cleaned up from the temporary folder: [#4335](https://github.com/owncloud/android/issues/4335)
* Bugfix - Resolve incorrect truncation of long display names in Manage Accounts: [#4351](https://github.com/owncloud/android/issues/4351)
* Change - Upgrade minimum SDK version to Android 7.0 (v24): [#4230](https://github.com/owncloud/android/issues/4230)
Expand Down Expand Up @@ -69,6 +70,14 @@ ownCloud admins and users.
https://github.com/owncloud/android/issues/4309
https://github.com/owncloud/android/pull/4350

* Bugfix - Video streaming in spaces: [#4328](https://github.com/owncloud/android/issues/4328)

The URI formed to perform video streaming in spaces has been adapted to oCIS
accounts so that it takes into account the space where the file is located.

https://github.com/owncloud/android/issues/4328
https://github.com/owncloud/android/pull/4394

* Bugfix - Retried successful uploads are cleaned up from the temporary folder: [#4335](https://github.com/owncloud/android/issues/4335)

Temporary files related to a failed upload are deleted after retrying it and
Expand Down
7 changes: 7 additions & 0 deletions changelog/unreleased/4394
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Bugfix: Video streaming in spaces

The URI formed to perform video streaming in spaces has been adapted to oCIS accounts so that it takes into account the
space where the file is located.

https://github.com/owncloud/android/issues/4328
https://github.com/owncloud/android/pull/4394
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,11 @@ class ReleaseNotesViewModel(
subtitle = R.string.release_notes_4_3_0_subtitle_search_functionality_in_spaces_list,
type = ReleaseNoteType.ENHANCEMENT
),
ReleaseNote(
title = R.string.release_notes_4_3_0_title_video_streaming_spaces,
subtitle = R.string.release_notes_4_3_0_subtitle_video_streaming_spaces,
type = ReleaseNoteType.BUGFIX
),
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,18 +39,23 @@
import androidx.media3.extractor.DefaultExtractorsFactory;
import com.owncloud.android.MainApp;
import com.owncloud.android.domain.files.model.OCFile;
import com.owncloud.android.domain.files.usecases.GetWebDavUrlForSpaceUseCase;
import com.owncloud.android.lib.common.accounts.AccountUtils;
import com.owncloud.android.lib.common.authentication.OwnCloudBasicCredentials;
import com.owncloud.android.lib.common.authentication.OwnCloudBearerCredentials;
import com.owncloud.android.lib.common.authentication.OwnCloudCredentials;
import com.owncloud.android.lib.common.network.WebdavUtils;
import com.owncloud.android.utils.UriUtilsKt;
import kotlin.Lazy;
import timber.log.Timber;

import java.io.IOException;
import java.lang.ref.WeakReference;
import java.util.HashMap;
import java.util.Map;

import static org.koin.java.KoinJavaComponent.inject;

/**
* Task for prepare video player asynchronously
*/
Expand All @@ -77,23 +82,26 @@ protected MediaSource doInBackground(Object... params) {

MediaSource mediaSource = null;

Uri uri;

try {
// If the file is already downloaded, reproduce it locally, if not, do streaming
uri = mFile.isAvailableLocally() ? UriUtilsKt.INSTANCE.getStorageUriForFile(mFile) :
Uri.parse(AccountUtils.getWebDavUrlForAccount(mContext, mAccount) + Uri.encode(mFile.getRemotePath(), "/"));

boolean useBandwidthMeter = true;

DefaultBandwidthMeter bandwidthMeter = useBandwidthMeter ? BANDWIDTH_METER : null;
Uri uri;
if (mFile.isAvailableLocally()) {
uri = UriUtilsKt.INSTANCE.getStorageUriForFile(mFile);
} else {
Lazy<GetWebDavUrlForSpaceUseCase> getWebDavUrlForSpaceUseCaseLazy = inject(GetWebDavUrlForSpaceUseCase.class);
String spaceWebDavUrl = getWebDavUrlForSpaceUseCaseLazy.getValue().invoke(
new GetWebDavUrlForSpaceUseCase.Params(mFile.getOwner(), mFile.getSpaceId())
);
String webDavUrl = spaceWebDavUrl == null ? AccountUtils.getWebDavUrlForAccount(mContext, mAccount) : spaceWebDavUrl;
uri = Uri.parse(webDavUrl + WebdavUtils.encodePath(mFile.getRemotePath()));
}

HttpDataSource.Factory httpDataSourceFactory =
buildHttpDataSourceFactory(bandwidthMeter, mFile, mAccount);
buildHttpDataSourceFactory(BANDWIDTH_METER, mFile, mAccount);

// Produces DataSource instances through which media data is loaded.
DataSource.Factory mediaDataSourceFactory = new DefaultDataSourceFactory(mContext,
bandwidthMeter, httpDataSourceFactory);
BANDWIDTH_METER, httpDataSourceFactory);

// This represents the media to be played.
mediaSource = buildMediaSource(mediaDataSourceFactory, uri);
Expand Down
2 changes: 2 additions & 0 deletions owncloudApp/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -754,6 +754,8 @@
<string name="release_notes_4_3_0_subtitle_improve_available_offline_performance">Files contained in an available offline folder will be refreshed only if they have been modified</string>
<string name="release_notes_4_3_0_title_search_functionality_in_spaces_list">Search functionality in spaces list</string>
<string name="release_notes_4_3_0_subtitle_search_functionality_in_spaces_list">Search functionality has been added in spaces list when you are trying to filter them</string>
<string name="release_notes_4_3_0_title_video_streaming_spaces">Video streaming in spaces</string>
<string name="release_notes_4_3_0_subtitle_video_streaming_spaces">Video files located in spaces can now be played in streaming correctly</string>

<!-- Open in web -->
<string name="ic_action_open_in_web">Open in web</string>
Expand Down

0 comments on commit bc5c42f

Please sign in to comment.