Skip to content

Video streaming - #1907

Merged
davivel merged 72 commits into
masterfrom
video_streaming
Mar 21, 2017
Merged

davivel merged 72 commits into
masterfrom
video_streaming

Conversation

@davigonz

Copy link
Copy Markdown
Contributor

Implements the feature of the issue #592

@mention-bot

Copy link
Copy Markdown

@davigonz, thanks for your PR! By analyzing the history of the files in this pull request, we identified @davivel, @stoyicker and @jabarros to be potential reviewers.

@davigonz

Copy link
Copy Markdown
Contributor Author

@jesmrec , @jabarros This new feature is completed, pending to review and pass QA

@davivel davivel left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Please, see my comments.

@jesmrec , maybe testing should be blocked until changes are applied.

Comment thread AndroidManifest.xml Outdated
<activity android:name=".ui.activity.PrivacyPolicyActivity"></activity>
<activity android:name=".ui.preview.PreviewVideoActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize|screenLayout|smallestScreenSize|uiMode"
android:launchMode="singleTop"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why in "singleTop" mode?

Comment thread build.gradle

configurations.all {
resolutionStrategy {
force "com.android.support:support-annotations:${supportLibraryVersion}"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why is this needed?

@davigonz davigonz Mar 9, 2017 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

To fix this conflict which has been triggered while adding the Exoplayer library dependency:

Conflict with dependency 'com.android.support:support-annotations' in project 'android'. Resolved versions for app (25.0.1) and test app (24.2.1) differ.

Comment thread res/layout/preview_video_fragment.xml Outdated

<VideoView
android:id="@+id/video_preview"
<com.google.android.exoplayer2.ui.SimpleExoPlayerView android:id="@+id/video_preview_fragment"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why the change in the name from 'video_preview' to 'video_preview_fragment'? SimpleExoPlayerView is not a Fragment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Mmmm, this file is not being used anymore. Both the PreviewVideoFragment and PreviewActivity use res/layout/video_player.xml. Please, remove one of them

app:controller_layout_id="@layout/custom_playback_control"/>

<!-- last to draw, will be top in Z axis -->
<include layout="@layout/top_progress_bar"/>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Is this progress bar really needed here?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yes, it is used when the certificate is untrusted and the video file starts to download automatically

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

👍

Comment thread res/values/strings.xml Outdated
<string name="privacy_policy_error">"An error has occurred: "</string>
<string name="service_unavailable">Server is unavailable</string>

<string name="uploads_view_upload_status_failed_storage_not_available_error">Storage not available</string>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This string is not used. Please, remove it. Probably it's inherited from other branch where it was later renamed or deleted, before merging into master.

@davigonz davigonz Mar 9, 2017 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Deleted



/**
* Created by davidgonzalez on 22/2/17.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Automated comment?

final GetCredentialsTask task = new GetCredentialsTask();
task.execute(account);

OwnCloudCredentials credentials = task.get();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This will not work fine.

You run a task as an AsyncTask because you want it occurs in another thread, because the task is too long and don't want the current thread (probably the main thread) uses all that time in this.

But then you call task.get(), and that waits in the current thread until the task is finished.

So, in the end, this works just exactly as if you do not use an AsyncTask, but with more code. Not a good deal.

@davigonz davigonz Mar 10, 2017 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Updated, using the AsyncTask for preparing the video player instead of only using it for getting the credentials.

protected OwnCloudCredentials doInBackground(Object... params) {
Object account = params[0];
try {
OwnCloudCredentials ocCredentials = AccountUtils.getCredentialsForAccount(MainApp.getAppContext(), (Account) account);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Line too long.

*
* {@inheritDoc}
*/
private static final DefaultBandwidthMeter BANDWIDTH_METER = new DefaultBandwidthMeter();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why static?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Not needed, changed

public void onResume() {
super.onResume();
Log_OC.v(TAG, "onResume");
if ((Util.SDK_INT <= 23 || player == null)) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why the difference depending on API level? Just curious.

@davigonz davigonz Mar 10, 2017 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I'm not sure about this, I've gotten this part from the Exoplayer demo example. At first glance, it has no sense but I would have to check it.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I've definitely deleted it, not needed.

@@ -0,0 +1,33 @@
<?xml version="1.0" encoding="UTF-8"?>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Maybe we should rename this as preview_video_fragment, for consistency with the other layouts.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Renaming it as preview_video_fragment could be confusing because this layout is currently being used in the preview video fragment and also in the full screen mode, when any fragment is shown.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Yes, I know. OK, not really important.

Comment thread res/values/strings.xml Outdated
<string name="streaming_file_not_found_error">This video file is no longer available in the server</string>
<string name="previewing_video_common_error">This video cannot be reproduced</string>

<string name="previewing_video_not_supported">Video previewing is not supported in your Android version. File download will start automatically and you will be able to open it with an external player</string>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This error message was the same in the previous review? Seems too long. Do you think that explaining that file download will be done is needed? Should be quite obvious.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This error message is not the same as the previous review, the one you mean is just above it (previewing_video_common_error). This (previewing_video_not_supported) is particularly shown while using ICE CREAM SANDWICH devices.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

OK, thought I would use "Video streaming is not supported in your Android version"

Moreover, I would not even show an error. Just would download the file. That's what already happens in the released app, the expectation does not have to change.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Also, you considered ICE CREAM SANDWICH edge case in PreviewMediaFragment, but not in PreviewVideoActivity.

@davigonz davigonz Mar 14, 2017 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yes, I prefer your error message but I don't agree with you about not showing the error message. It's the current behaviour in the released app but we should give feedback to the user as much as possible. If the user see that the download starts automatically, he will wonder why.

ICE CREAM SANDWICH is only considered in PreviewVideoFragment because there is no way to go into full screen mode if the video player is not still prepared (full screen button is hidden till the video player is prepared)

public PrepareVideoPlayerAsyncTask(Activity activity, OCFile file, Account account,
Handler mainHandler) {
mContext = activity.getApplicationContext();
mListener = new WeakReference<>((OnPrepareVideoPlayerTaskListener)activity);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I'd rather use OnPrepareVideoPlayerTaskListener as the parameter type, that would prevent the need of a casting.

@davigonz davigonz Mar 14, 2017 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Casting from activity to OnPrepareVideoPlayerTaskListener would be needed anyway even though the mListener be OnPrepareVideoPlayerTaskListener.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Better in the client of the call than in the implementation. In this method, you are requesting your future callers for a parameter with a concrete interface, but you never use it according to that interface - you use the object with another interface totally unrelated. A client not knowing the method implementation could pass just any Activity, not implementing OnPrepareVideoPlayerTaskListener , and get the task fail. What the method really needs is an OnPrepareVideoPlayerTaskListener that is what should request.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yes, you're right, but I've followed the same implementation as AuthenticatorAsyncTask, which constructor is doing the casting in the same way.

Here it is: https://github.com/owncloud/android/blob/master/src/com/owncloud/android/authentication/AuthenticatorAsyncTask.java

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Yes, but AuthenticatorAsyncTask is using the Activity as an Activity:

mContext = activity.getApplicationContext()

This other AsyncTask is not doing so.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

WT... this AsyncTask is doing so... Sorry, I don't know how I missed that.

In any case, would be wiser to include two different parameters in the interface, one for the Activity and one for the listener. If the client passes a single object for them is up to it.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This AsyncTask is doing so actually, I've changed the casting to the callers anyway


try {

OwnCloudCredentials credentials = AccountUtils.getCredentialsForAccount(MainApp.getAppContext(), account);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Line too long.

@davivel

davivel commented Mar 14, 2017

Copy link
Copy Markdown
Contributor

@davigonz , just a couple of minors, overall is OK.

@davivel

davivel commented Mar 15, 2017

Copy link
Copy Markdown
Contributor

Ready to go; @jesmrec , your call.

@jesmrec

jesmrec commented Mar 21, 2017

Copy link
Copy Markdown
Member

Approved

CC @davigonz @davivel

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants