fix(ios): ensure orientation is correct on iOS (#3719)
* fix(ts): onPlaybackRateChangeData was not correctly typed * fix: ensure tracks are well displayed in the sample * fix(iOS): ensure orientation is correctly reported * chore: fix build
This commit is contained in:
parent
a1090a1639
commit
1a8295c8bf
@ -203,7 +203,7 @@ Payload:
|
|||||||
| ----------- | ------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
| ----------- | ------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
||||||
| currentTime | number | Time in seconds where the media will start |
|
| currentTime | number | Time in seconds where the media will start |
|
||||||
| duration | number | Length of the media in seconds |
|
| duration | number | Length of the media in seconds |
|
||||||
| naturalSize | object | Properties:<br/> _ width - Width in pixels that the video was encoded at<br/> _ height - Height in pixels that the video was encoded at<br/> \* orientation - "portrait" or "landscape" |
|
| naturalSize | object | Properties:<br/> _ width - Width in pixels that the video was encoded at<br/> _ height - Height in pixels that the video was encoded at<br/> \* orientation - "portrait", "landscape" or "square" |
|
||||||
| audioTracks | array | An array of audio track info objects with the following properties:<br/> _ index - Index number<br/> _ title - Description of the track<br/> _ 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<br/> _ type - Mime type of track |
|
| audioTracks | array | An array of audio track info objects with the following properties:<br/> _ index - Index number<br/> _ title - Description of the track<br/> _ 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<br/> _ type - Mime type of track |
|
||||||
| textTracks | array | An array of text track info objects with the following properties:<br/> _ index - Index number<br/> _ title - Description of the track<br/> _ 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<br/> _ type - Mime type of track |
|
| textTracks | array | An array of text track info objects with the following properties:<br/> _ index - Index number<br/> _ title - Description of the track<br/> _ 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<br/> _ type - Mime type of track |
|
||||||
| videoTracks | array | An array of video track info objects with the following properties:<br/> _ trackId - ID for the track<br/> _ bitrate - Bit rate in bits per second<br/> _ codecs - Comma separated list of codecs<br/> _ height - Height of the video<br/> \* width - Width of the video |
|
| videoTracks | array | An array of video track info objects with the following properties:<br/> _ trackId - ID for the track<br/> _ bitrate - Bit rate in bits per second<br/> _ codecs - Comma separated list of codecs<br/> _ height - Height of the video<br/> \* width - Width of the video |
|
||||||
|
@ -104,9 +104,13 @@ class VideoPlayer extends Component {
|
|||||||
|
|
||||||
srcAllPlatformList = [
|
srcAllPlatformList = [
|
||||||
{
|
{
|
||||||
description: 'local file',
|
description: 'local file landscape',
|
||||||
uri: require('./broadchurch.mp4'),
|
uri: require('./broadchurch.mp4'),
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
description: 'local file portrait',
|
||||||
|
uri: require('./portrait.mp4'),
|
||||||
|
},
|
||||||
{
|
{
|
||||||
description: '(hls|live) red bull tv',
|
description: '(hls|live) red bull tv',
|
||||||
uri: 'https://rbmn-live.akamaized.net/hls/live/590964/BoRB-AT/master_928.m3u8',
|
uri: 'https://rbmn-live.akamaized.net/hls/live/590964/BoRB-AT/master_928.m3u8',
|
||||||
|
BIN
examples/basic/src/portrait.mp4
Normal file
BIN
examples/basic/src/portrait.mp4
Normal file
Binary file not shown.
@ -1290,8 +1290,8 @@ class RCTVideo: UIView, RCTVideoPlayerViewControllerDelegate, RCTPlayerObserverH
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var width: Float?
|
var width: Float = 0
|
||||||
var height: Float?
|
var height: Float = 0
|
||||||
var orientation = "undefined"
|
var orientation = "undefined"
|
||||||
|
|
||||||
Task {
|
Task {
|
||||||
@ -1299,20 +1299,11 @@ class RCTVideo: UIView, RCTVideoPlayerViewControllerDelegate, RCTPlayerObserverH
|
|||||||
if let videoTrack = tracks?.first {
|
if let videoTrack = tracks?.first {
|
||||||
width = Float(videoTrack.naturalSize.width)
|
width = Float(videoTrack.naturalSize.width)
|
||||||
height = Float(videoTrack.naturalSize.height)
|
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 {
|
} else if _playerItem.presentationSize.height != 0.0 {
|
||||||
width = Float(_playerItem.presentationSize.width)
|
width = Float(_playerItem.presentationSize.width)
|
||||||
height = Float(_playerItem.presentationSize.height)
|
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 {
|
if self._pendingSeek {
|
||||||
self.setSeek([
|
self.setSeek([
|
||||||
@ -1342,8 +1333,8 @@ class RCTVideo: UIView, RCTVideoPlayerViewControllerDelegate, RCTPlayerObserverH
|
|||||||
"canStepBackward": NSNumber(value: _playerItem.canStepBackward),
|
"canStepBackward": NSNumber(value: _playerItem.canStepBackward),
|
||||||
"canStepForward": NSNumber(value: _playerItem.canStepForward),
|
"canStepForward": NSNumber(value: _playerItem.canStepForward),
|
||||||
"naturalSize": [
|
"naturalSize": [
|
||||||
"width": width != nil ? NSNumber(value: width!) : "undefinded",
|
"width": width,
|
||||||
"height": width != nil ? NSNumber(value: height!) : "undefinded",
|
"height": height,
|
||||||
"orientation": orientation,
|
"orientation": orientation,
|
||||||
],
|
],
|
||||||
"audioTracks": audioTracks,
|
"audioTracks": audioTracks,
|
||||||
|
Loading…
Reference in New Issue
Block a user