Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(VideoAsset): handle unplayable videos [WPB-11667] #18200

Merged
merged 4 commits into from
Oct 24, 2024

Conversation

olafsulich
Copy link
Contributor

@olafsulich olafsulich commented Oct 24, 2024

TaskWPB-11667 [Web] Display unsupported video as file + countly event

Description

Handles unsupported videos:

  • if we can detect unsupported mime type => display it as a file
Screenshot 2024-10-24 at 08 12 19
  • if we have to perform more advanced checks, e.g. to detect unsupported codecs => error message + download button (consulted with Design)
Screenshot 2024-10-24 at 08 05 29

I added logs to Countly, let's measure how big the problem is.

Checklist

  • mentions the JIRA issue in the PR name (Ex. WPB-423)
  • PR has been self reviewed by the author;
  • Hard-to-understand areas of the code have been commented;
  • [] If it is a core feature, unit tests have been added;

Copy link

sonarcloud bot commented Oct 24, 2024

@codecov-commenter
Copy link

codecov-commenter commented Oct 24, 2024

Codecov Report

Attention: Patch coverage is 3.03030% with 32 lines in your changes missing coverage. Please review.

Project coverage is 46.40%. Comparing base (1287d9a) to head (4ce3fa0).
Report is 4 commits behind head on dev.

Additional details and impacted files
@@           Coverage Diff           @@
##              dev   #18200   +/-   ##
=======================================
  Coverage   46.39%   46.40%           
=======================================
  Files         797      800    +3     
  Lines       25798    25827   +29     
  Branches     5886     5888    +2     
=======================================
+ Hits        11970    11984   +14     
- Misses      12326    12337   +11     
- Partials     1502     1506    +4     

@przemvs
Copy link
Contributor

przemvs commented Oct 24, 2024

We want to display big placeholder for unsupported video? :)

@olafsulich
Copy link
Contributor Author

We want to display big placeholder for unsupported video? :)

@przemvs It's the size of the video player, hmm I wouldn't shrink that down. Imagine you click the play button, and then, because of the error, the player disappears and some smaller error message shows up 😕

Screen.Recording.2024-10-24.at.09.26.15.mov

Copy link
Contributor

@e-maad e-maad left a comment

Choose a reason for hiding this comment

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

LGTM 🚀
Added few comments, please have a look.

// It's not 100% reliable (e.g. doesn't check codecs), but it's synchorous, which is helpful for initial rendering.
const isVideoMimeTypeSupported = (mimeType: string): boolean => {
const video = document.createElement('video');
const canPlay = video.canPlayType(mimeType) !== '';
Copy link
Contributor

Choose a reason for hiding this comment

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

Just a suggestion, if we create an enum for the return types it would be more readable:
https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement/canPlayType#return_value

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't think that's necessary because we don't use it directly - we just check that it's not an empty string.

@@ -153,6 +205,7 @@ const VideoAsset: React.FC<VideoAssetProps> = ({
poster={videoPreview?.url}
onError={event => {
setVideoPlaybackError(true);
amplify.publish(WebAppEvents.ANALYTICS.EVENT, EventName.MESSAGES.VIDEO.PLAY_FAILED);
Copy link
Contributor

Choose a reason for hiding this comment

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

There are 4 place where we logged PLAY_FAILED event.
Just curious if it will only log once per error.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've checked and it shouldn't fire a few at once.

  1. fires when mime type is not supported (the simple check)
  2. fires when a video is not playable (the advanced check)
  3. fires when something fails in the try{} block inside onPlayButtonClicked (e.g. getAssetUrl function)
  4. fires on the video error callback - I guess now it's not gonna be a common case (because we handled unplayable videos before that), but in case something fails, then we can log it

I wanted to add logs in many places, so that we can later analyse how many videos were played successfully, how many ended with "unsupported mime type", and how many failed due to unsupported codecs.

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks for explanation 🚀

@olafsulich olafsulich merged commit 05aeb6a into dev Oct 24, 2024
14 checks passed
@olafsulich olafsulich deleted the feat/WPB-11667-display-unplayable-video-as-file branch October 24, 2024 09:54
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.

5 participants