-
Notifications
You must be signed in to change notification settings - Fork 4.7k
[Mobile]Add video block (first iteration) #14912
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
Conversation
# Conflicts: # packages/block-library/src/index.native.js
# Conflicts: # packages/block-library/src/index.native.js
| if ( typeof __DEV__ === 'undefined' || ! __DEV__ ) { | ||
| unregisterBlockType( 'core/code' ); | ||
| unregisterBlockType( 'core/more' ); | ||
| unregisterBlockType( 'core/video' ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added this so we won't see this on production yet
| border-bottom-left-radius: $play-icon-size/8; | ||
| border-bottom-right-radius: $play-icon-size/8; | ||
| border-top-right-radius: $play-icon-size/8; | ||
| border-top-left-radius: $play-icon-size/8; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know why but I am getting red screen if I just use border-radius
| @@ -0,0 +1,151 @@ | |||
| /** | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a new component to be used by both video and image blocks(and probably by other media upload blocks in the future). It is actually not new code, just extracted from image block.
It listens to media upload events coming from main apps and updates progress Spinner. It also provides a way to render a child component with the current upload state(see props.renderContent) If provided a coverUrl then it will also calculate width, height of the image and pass to renderContent.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe a better place for this component would be media-upload/? Since it's meant to be shared between media related blocks.
It also looks like a good candidate for a HOC (not 100% sure). This might also make easier its implementation in blocks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @etoledom 👍 I added a tech debt here wordpress-mobile/gutenberg-mobile#687 (comment)
| @@ -0,0 +1,98 @@ | |||
| /** | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a new component to be used by both video and image blocks also by MediaUpload component. It is actually not new code, just extracted from image block.
This component is responsible for displaying media options picker to user. It is designed similar to what web has, it passes a function 'open' via its render method and the rendering component decides when to call that function.
Different thing is web doesn't need to pass getMediaOptions but we do, the rendering component also needs to embed getMediaOptions() call to an appropriate place. I tried wrapping this component with a View and calling getMediaOptions() inside, but that messed up the layout of edit button. 🤷♀️
| */ | ||
| import styles from './styles.scss'; | ||
|
|
||
| function MediaPlaceholder( props ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We are making MediaPlaceholder usable by both image and video blocks by passing media type.
| </Text> | ||
| </View> | ||
| </TouchableWithoutFeedback> | ||
| <MediaUpload |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We are also using our new MediaUpload component here.
| return ( | ||
| <View onLayout={ this.onVideoContanerLayout } style={ { flex: 1 } }> | ||
| { showVideo && | ||
| <Video |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
By using this video component we are coming close to what web side has.
| } } | ||
| // Using built-in player controls is messing up the layout on iOS. | ||
| // So we are setting controls=false and adding a play button that | ||
| // will trigger presentFullscreenPlayer() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good as a workaround for this PR, but let's make sure to track this in another issue for 2.0.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've added a new item to the TODO list here: wordpress-mobile/gutenberg-mobile#687
Unfortunately this is in library level, they are setting the frame (as a workaround for some issue) when controls=true
https://github.com/react-native-community/react-native-video/blob/c30f246f5694452f4f081ff30ac4523dfd89f41d/ios/Video/RCTVideo.m#L593
And by doing that they are messing up the y position of our page. I couldn't come up with a nice solution myself, I was planning to open an issue to their repo after this is merged. I think they might agree that current way is not very healthy. I can also try to tackle this more and send a PR to the original repo if they ignore the issue in the long run 🤔
# Conflicts: # packages/block-editor/src/components/media-placeholder/index.native.js # packages/block-library/src/image/edit.native.js
# Conflicts: # packages/block-editor/src/components/media-placeholder/index.native.js
| componentDidMount() { | ||
| const { attributes, setAttributes } = this.props; | ||
| if ( attributes.id && ! isURL( attributes.src ) ) { | ||
| if ( attributes.url.indexOf( 'file:' ) === 0 ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @pinarol @SergioEstevao do we need this block of code as it was put for copy/paste images on iOS but not sure for videos?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like we don't have support for video copy paste on Aztec either. So yes, we don't need this code, let me remove that.
We are not supporting video copy paste, that code was copy/paste from image block
poster support isn't present on wp.com yet and react-native-video has an ugly bug about posters so we'll need to solve that first, after that we'll re-add this.
etoledom
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for all this great hard work @pinarol !
It looks great and has been more than tested via wordpress-mobile/gutenberg-mobile#854 and wordpress-mobile/WordPress-iOS#11454 (for iOS).
I left a small code commen as a possible future optimization.
| @@ -0,0 +1,151 @@ | |||
| /** | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe a better place for this component would be media-upload/? Since it's meant to be shared between media related blocks.
It also looks like a good candidate for a HOC (not 100% sure). This might also make easier its implementation in blocks.
Description
To Fix: wordpress-mobile/gutenberg-mobile#855
This PR introduces the new video block for Mobile. First of all I am sorry for this huge PR. I will try to add notes and make it easier to understand as much as possible. Please note that most of the green changes aren't actually new code, they are mostly extracted from image block, I added some inline comments to point this out.
How has this been tested?
Tested via: wordpress-mobile/gutenberg-mobile#854
Types of changes
<video>tag, so hopefully any future abstractions will be easier to make the video block cross platform.I added some additional inline comments to describe what's done.
Checklist: