Skip to content

Commit

Permalink
Merge pull request #13 from react-native-oh-library/capi
Browse files Browse the repository at this point in the history
修复横竖屏切换异常问题
  • Loading branch information
Louis-C7 authored Apr 25, 2024
2 parents fd995d7 + 8571163 commit b366d86
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 12 deletions.
Binary file modified harmony/rn_video.har
Binary file not shown.
6 changes: 6 additions & 0 deletions harmony/rn_video/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/node_modules
/oh_modules
/.preview
/build
/.cxx
/.test
5 changes: 0 additions & 5 deletions harmony/rn_video/BuildProfile.ets

This file was deleted.

2 changes: 1 addition & 1 deletion harmony/rn_video/oh-package.json5
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"name": "@react-native-oh-tpl/react-native-video",
"description": "main cpai architecture",
"main": "index.ets",
"version": "5.2.1-0.2.3",
"version": "5.2.1-0.2.2",
"dependencies": {
"@rnoh/react-native-openharmony": "file:../react_native_openharmony"
}
Expand Down
11 changes: 7 additions & 4 deletions harmony/rn_video/src/main/ets/RNCVideo.ets
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,12 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/

import {
Descriptor,
RNOHContext,
ViewDynamicProps,
ViewBaseProps,
RNViewBase,
ComponentBuilderContext,
RNComponentFactory
} from '@rnoh/react-native-openharmony'

import { PlayPlayer } from './view/PlayPlayer';
Expand Down Expand Up @@ -120,9 +118,11 @@ export struct RNCVideo {
videoWidth: number|string = CommonConstants.FULL_PERCENT;
@Provide
changedViewWidth:number = 0
@Provide
changedviewHeight:number = 0

aboutToAppear() {
Logger.debug(`RNOH in RNCVideo aboutToAppear !}`);
Logger.debug(`RNOH in RNCVideo aboutToAppear 修改后 !}`);
this.descriptor = this.ctx.descriptorRegistry.getDescriptor<VideoViewDescriptor>(this.tag)
Logger.debug(`RNOH in RNCVideo descriptor props, ${JSON.stringify(this.descriptor.props)}`);
Logger.debug(`RNOH in RNCVideo descriptor layoutMetrics, ${JSON.stringify(this.descriptor.layoutMetrics)}`);
Expand All @@ -135,8 +135,10 @@ export struct RNCVideo {
this.updatePropFromDesc()
this.preparePlayer();
this.videoWidth = this.viewWidth
this.videoHeight = this.viewHeight
if(display.getDefaultDisplaySync().orientation == 0 || display.getDefaultDisplaySync().orientation == 2){
this.videoWidth = CommonConstants.FULL_PERCENT;
this.videoHeight = CommonConstants.FULL_PERCENT;
}


Expand Down Expand Up @@ -186,6 +188,7 @@ export struct RNCVideo {
this.viewWidth = this.descriptor.layoutMetrics.frame.size.width
this.viewHeight = this.descriptor.layoutMetrics.frame.size.height
this.changedViewWidth = this.viewWidth
this.changedviewHeight = this.viewHeight
}

/**
Expand Down
4 changes: 3 additions & 1 deletion harmony/rn_video/src/main/ets/view/PlayPlayer.ets
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ export struct PlayPlayer {
viewHeight:number = 0
@Consume
changedViewWidth:number
@Consume
changedviewHeight:number

aboutToAppear() {
if (this.playVideoModel) {
Expand Down Expand Up @@ -146,7 +148,7 @@ export struct PlayPlayer {
.scale(this.matrix)
}
.width(this.changedViewWidth)
.height(this.viewHeight)
.height(this.changedviewHeight)
.alignItems(this.videoAlignItems)
.justifyContent(this.videoJustifyContent)
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@react-native-oh-tpl/react-native-video",
"version": "5.2.1-0.2.3",
"version": "5.2.1-0.2.2",
"description": "A <Video /> element for react-native",
"harmony": {
"alias": "react-native-video"
Expand Down

0 comments on commit b366d86

Please sign in to comment.