fix(tapping-video): tapping the video should play/pause #723
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem:
Users currently cannot toggle play/pause by tapping on the video in our media player. The acceptance criteria specify that tapping on the video when not playing should play the video, and tapping on the video when it is playing should pause the video.
Solution:
I implemented a toggle play/pause functionality by attaching an
onClick
event handler to theReactPlayer
component. This handler changes the play state based on the current state of the video, allowing users to tap the video to play or pause it.Changes:
handleVideoClick
Function: Created a function to toggle the play state between play and pause.onClick
Handler to ReactPlayer: TheReactPlayer
component now has anonClick
event that triggers thehandleVideoClick
function.Here are the specific code changes:
Within MediaPlayerComponent:
Added a
handleVideoClick
method to toggleisPlaying
state.Attached this method to the ReactPlayer component's onClick event.
Modifications in JSX:
<Wrapper hidden={hidden} onClick={handleVideoClick}>
to ensure the entire player area is clickable.Evidence:
A short demo video was recorded showing the new functionality in action. It demonstrates the ease with which a user can now play or pause the video with a simple tap, highlighting the responsiveness and effectiveness of the implemented solution.
Testing:
Notes:
Please review the changes and merge this PR if everything is in order. This fix is essential for the upcoming release, and I look forward to any feedback you might have.