Skip to content

Conversation

@tobiasKaminsky
Copy link
Member

@tobiasKaminsky tobiasKaminsky commented Apr 27, 2018

Needs:

Fixes: #379

This enables video/audio streaming without exposing any credentials.

Test cases:
NC14

  • non downloaded file
    • stream video internally
      • toggle to fullscreen
    • stream audio internally
    • stream video with external app
    • stream audio with external app
  • downloaded file
    • play video/audio directly

NC13

  • no option to stream
  • non downloaded file
    • download media, then play
  • downloaded file
    • play video/audio directly

Signed-off-by: tobiasKaminsky tobias@kaminsky.me

@tobiasKaminsky
Copy link
Member Author

For such PR that need a library PR, I guess the best is to reference the branch directly, or?
Problem will be, when we merge the corresponding PR, then there is no PR and the build fails. Then we would have to use master until we release a new library version, otherwise any other client PR will fail.

--> I am not sure how to handle this best…

// Parse the response
JSONObject respJSON = new JSONObject(response);
String url = (String) respJSON.getJSONObject(NODE_OCS).getJSONObject(NODE_DATA).get(NODE_URL);

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

couldn't you just use getString instead of get()+cast ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed 👍

@mario
Copy link
Contributor

mario commented Apr 27, 2018

Shouldn't stream just be the default instead of having a dedicated stream menu button? What does "stream" means to say, my grandma?

@nextcloud nextcloud deleted a comment Apr 27, 2018
mFileActivity.startActivity(Intent.createChooser(openFileWithIntent,
mFileActivity.getString(R.string.stream)));
}
}).start();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

optional: What about using a lambda and putting the whole run() code into a separate method?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup please.


new LoadStreamUrl(this, client).execute(getFile().getLocalId());
} catch (Exception e) {
Log_OC.e(TAG, "Loading stream url not possible: " + e.getMessage());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't we also add the exception itself to the log statement?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

R.string.stream_not_possible_message, R.drawable.file_movie);
}
} else {
Log_OC.e(TAG, "Error streaming file: no previewMediaFragment!");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here: shouldn't we also add the exception itself to the log statement?

Copy link
Member Author

@tobiasKaminsky tobiasKaminsky Jun 27, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here is no exception.
It happens when fragment is null.

@AndyScherzinger
Copy link
Member

Just some minor code comments

Shouldn't stream just be the default instead of having a dedicated stream menu button?

I agree it should be the default cation when clicking on an item (that can be streamed in general) and I remember that this is also what Tobias told me :)

@tobiasKaminsky
Copy link
Member Author

It is: if you click on audio/video it will try to stream the file with our internal player.
You can also open the overflow menu and select "stream with…" to directly open up the file in e.g. vlc.

If our internal player fails, it says "Please download media instead or use external app.".

return mMediaController;
}

private static class LoadStreamUrl extends AsyncTask<String, Void, String> {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there no other way but an AsyncTask? I thought we got rid of this ages ago :P

@mario
Copy link
Contributor

mario commented May 22, 2018

To further clarify my comment on AsyncTasks:

TobiasK: as for media streaming: I'd appreciate if we'd move away from asynctasks, especially for new code
even a service-based download + eventbus/interface download notification would work better
but I guess you could go for a Job + eventbus notification too, which would make it cleeeeeaner :)

@tobiasKaminsky
Copy link
Member Author

For up/downloading I agree to use services or jobs/eventbus.
But for this we need to have this executed as soon as possible as it fetches the video streaming url.

So I would go for this:

  • if it "urgent"/ as soon as possible, use asyncTask (afaik it is still the recommended way of android to show results of small background options on the UI).
  • all other, especially things that are really asynchronous, like upload/download, keep-up-to-date should be done via jobs, so that android doze and other battery optimizations can take care of it

@mario
Copy link
Contributor

mario commented May 22, 2018

Ah. Service or Job can be ran right away too, but I just noticed that it's a simple fetching of url, not of an actual image.

Regardless, shouldn't we do it differently in a way that survives rotations etc instead of having to worry about these things?

@rullzer
Copy link
Member

rullzer commented Jun 27, 2018

Would be great to get this in. NC14 will go into freeze soon. So having a client that uses it will allow us to properly test it.

@tobiasKaminsky
Copy link
Member Author

Rebased & ready for final review

@AndyScherzinger
Copy link
Member

AndyScherzinger commented Jun 27, 2018

👍 fine by me :)

Approved with PullApprove

@codecov
Copy link

codecov bot commented Jun 27, 2018

Codecov Report

Merging #2524 into master will increase coverage by 0.02%.
The diff coverage is 0%.

@@            Coverage Diff            @@
##           master   #2524      +/-   ##
=========================================
+ Coverage     6.4%   6.42%   +0.02%     
=========================================
  Files         294     297       +3     
  Lines       29450   29709     +259     
  Branches     4252    4284      +32     
=========================================
+ Hits         1885    1910      +25     
- Misses      27278   27515     +237     
+ Partials      287     284       -3
Impacted Files Coverage Δ
...cloud/android/ui/helpers/FileOperationsHelper.java 0% <0%> (ø) ⬆️
...cloud/android/ui/preview/PreviewVideoActivity.java 0% <0%> (ø) ⬆️
.../java/com/owncloud/android/media/MediaService.java 0% <0%> (ø) ⬆️
...cloud/android/ui/preview/PreviewMediaFragment.java 0% <0%> (ø) ⬆️
...cloud/android/ui/activity/FileDisplayActivity.java 0% <0%> (ø) ⬆️
...ava/com/owncloud/android/files/FileMenuFilter.java 0% <0%> (ø) ⬆️
...ncloud/android/files/StreamMediaFileOperation.java 0% <0%> (ø)
...ncloud/android/ui/fragment/OCFileListFragment.java 0% <0%> (ø) ⬆️
...ncloud/android/datamodel/SyncedFolderProvider.java 8.8% <0%> (-1.3%) ⬇️
.../owncloud/android/ui/activity/ToolbarActivity.java 0% <0%> (ø) ⬆️
... and 18 more

@AndyScherzinger
Copy link
Member

@tobiasKaminsky what about @mario's latest comment: #2524 (comment) ?

@tobiasKaminsky
Copy link
Member Author

Both loading url task are done when playing media, so I think it is fine.
Android Dev guide also recommends async task for short running calls.

Beside that, there is somewhere an issue, where I started a discussion how to do long running background tasks, that maybe even survive activity rotate/open/close.

--> I would keep it this way and later replace it with a potential better solution.

@AndyScherzinger
Copy link
Member

--> I would keep it this way and later replace it with a potential better solution.

Fine with me

@tobiasKaminsky
Copy link
Member Author

E.g. UserInfoActivity is the same:
open an account -> fetches data
rotate screen -> fetches data again

Of course, doing the same is not pushing the code to a better state, but I think we should find a better and generic approach first and then change it.

@nextcloud nextcloud deleted a comment Jul 3, 2018
@mario
Copy link
Contributor

mario commented Jul 12, 2018

👍

Approved with PullApprove

Signed-off-by: tobiasKaminsky <tobias@kaminsky.me>
Signed-off-by: tobiasKaminsky <tobias@kaminsky.me>
Signed-off-by: tobiasKaminsky <tobias@kaminsky.me>
Signed-off-by: tobiasKaminsky <tobias@kaminsky.me>
Signed-off-by: tobiasKaminsky <tobias@kaminsky.me>
Signed-off-by: tobiasKaminsky <tobias@kaminsky.me>
@nextcloud-android-bot
Copy link
Collaborator

Lint

This 93 warnings
Master 93 warnings

FindBugs (new)

Warning TypeNumber
Bad practice Warnings35
Correctness Warnings166
Experimental Warnings4
Internationalization Warnings12
Malicious code vulnerability Warnings9
Multithreaded correctness Warnings9
Performance Warnings158
Security Warnings163
Dodgy code Warnings207
Total763

FindBugs (master)

Warning TypeNumber
Bad practice Warnings35
Correctness Warnings166
Experimental Warnings4
Internationalization Warnings12
Malicious code vulnerability Warnings9
Multithreaded correctness Warnings9
Performance Warnings158
Security Warnings163
Dodgy code Warnings207
Total763

@nextcloud nextcloud deleted a comment Jul 13, 2018
@nextcloud nextcloud deleted a comment Jul 13, 2018
@nextcloud nextcloud deleted a comment Jul 13, 2018
@tobiasKaminsky tobiasKaminsky merged commit cdd3a56 into master Jul 13, 2018
@tobiasKaminsky tobiasKaminsky deleted the videoStreaming branch July 13, 2018 07:54
@AndyScherzinger AndyScherzinger added this to the Nextcloud App 3.3.0 milestone Jul 13, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants