diff --git a/docs/pages/component/events.mdx b/docs/pages/component/events.mdx index 654cca67df..a9c418de31 100644 --- a/docs/pages/component/events.mdx +++ b/docs/pages/component/events.mdx @@ -203,7 +203,7 @@ Payload: | ----------- | ------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | | currentTime | number | Time in seconds where the media will start | | duration | number | Length of the media in seconds | -| naturalSize | object | Properties:
_ width - Width in pixels that the video was encoded at
_ height - Height in pixels that the video was encoded at
\* orientation - "portrait" or "landscape" | +| naturalSize | object | Properties:
_ width - Width in pixels that the video was encoded at
_ height - Height in pixels that the video was encoded at
\* orientation - "portrait", "landscape" or "square" | | audioTracks | array | An array of audio track info objects with the following properties:
_ index - Index number
_ title - Description of the track
_ language - 2 letter [ISO 639-1](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) or 3 letter [ISO639-2](https://en.wikipedia.org/wiki/List_of_ISO_639-2_codes) language code
_ type - Mime type of track | | textTracks | array | An array of text track info objects with the following properties:
_ index - Index number
_ title - Description of the track
_ language - 2 letter [ISO 639-1](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) or 3 letter [ISO 639-2](https://en.wikipedia.org/wiki/List_of_ISO_639-2_codes) language code
_ type - Mime type of track | | videoTracks | array | An array of video track info objects with the following properties:
_ trackId - ID for the track
_ bitrate - Bit rate in bits per second
_ codecs - Comma separated list of codecs
_ height - Height of the video
\* width - Width of the video | diff --git a/examples/basic/src/VideoPlayer.tsx b/examples/basic/src/VideoPlayer.tsx index e437b2b19e..806fed1282 100644 --- a/examples/basic/src/VideoPlayer.tsx +++ b/examples/basic/src/VideoPlayer.tsx @@ -104,9 +104,13 @@ class VideoPlayer extends Component { srcAllPlatformList = [ { - description: 'local file', + description: 'local file landscape', uri: require('./broadchurch.mp4'), }, + { + description: 'local file portrait', + uri: require('./portrait.mp4'), + }, { description: '(hls|live) red bull tv', uri: 'https://rbmn-live.akamaized.net/hls/live/590964/BoRB-AT/master_928.m3u8', diff --git a/examples/basic/src/portrait.mp4 b/examples/basic/src/portrait.mp4 new file mode 100644 index 0000000000..0e4414c6f8 Binary files /dev/null and b/examples/basic/src/portrait.mp4 differ diff --git a/ios/Video/RCTVideo.swift b/ios/Video/RCTVideo.swift index d8f7f2a125..cf73fb5b9b 100644 --- a/ios/Video/RCTVideo.swift +++ b/ios/Video/RCTVideo.swift @@ -1290,8 +1290,8 @@ class RCTVideo: UIView, RCTVideoPlayerViewControllerDelegate, RCTPlayerObserverH } } - var width: Float? - var height: Float? + var width: Float = 0 + var height: Float = 0 var orientation = "undefined" Task { @@ -1299,20 +1299,11 @@ class RCTVideo: UIView, RCTVideoPlayerViewControllerDelegate, RCTPlayerObserverH if let videoTrack = tracks?.first { width = Float(videoTrack.naturalSize.width) height = Float(videoTrack.naturalSize.height) - let preferredTransform = videoTrack.preferredTransform - - if (videoTrack.naturalSize.width == preferredTransform.tx - && videoTrack.naturalSize.height == preferredTransform.ty) - || (preferredTransform.tx == 0 && preferredTransform.ty == 0) { - orientation = "landscape" - } else { - orientation = "portrait" - } } else if _playerItem.presentationSize.height != 0.0 { width = Float(_playerItem.presentationSize.width) height = Float(_playerItem.presentationSize.height) - orientation = _playerItem.presentationSize.width > _playerItem.presentationSize.height ? "landscape" : "portrait" } + orientation = width > height ? "landscape" : width == height ? "square" : "portrait" if self._pendingSeek { self.setSeek([ @@ -1342,8 +1333,8 @@ class RCTVideo: UIView, RCTVideoPlayerViewControllerDelegate, RCTPlayerObserverH "canStepBackward": NSNumber(value: _playerItem.canStepBackward), "canStepForward": NSNumber(value: _playerItem.canStepForward), "naturalSize": [ - "width": width != nil ? NSNumber(value: width!) : "undefinded", - "height": width != nil ? NSNumber(value: height!) : "undefinded", + "width": width, + "height": height, "orientation": orientation, ], "audioTracks": audioTracks,