fix(android): video resolution orientation android (#3862)
* fix(android): ensure width/heigh respect rotation of the video + Add rotation info in onVideoTrack event
This commit is contained in:
parent
c2ce66ed26
commit
b698b1837b
@ -12,4 +12,5 @@ class VideoTrack {
|
|||||||
var index = -1
|
var index = -1
|
||||||
var trackId = ""
|
var trackId = ""
|
||||||
var isSelected = false
|
var isSelected = false
|
||||||
|
var rotation = 0
|
||||||
}
|
}
|
||||||
|
@ -223,6 +223,7 @@ public class VideoEventEmitter {
|
|||||||
videoTrack.putString("trackId", vTrack.getTrackId());
|
videoTrack.putString("trackId", vTrack.getTrackId());
|
||||||
videoTrack.putInt("index", vTrack.getIndex());
|
videoTrack.putInt("index", vTrack.getIndex());
|
||||||
videoTrack.putBoolean("selected", vTrack.isSelected());
|
videoTrack.putBoolean("selected", vTrack.isSelected());
|
||||||
|
videoTrack.putInt("rotation", vTrack.getRotation());
|
||||||
waVideoTracks.pushMap(videoTrack);
|
waVideoTracks.pushMap(videoTrack);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1375,8 +1375,9 @@ public class ReactExoplayerView extends FrameLayout implements
|
|||||||
setSelectedTextTrack(textTrackType, textTrackValue);
|
setSelectedTextTrack(textTrackType, textTrackValue);
|
||||||
}
|
}
|
||||||
Format videoFormat = player.getVideoFormat();
|
Format videoFormat = player.getVideoFormat();
|
||||||
int width = videoFormat != null ? videoFormat.width : 0;
|
boolean isRotatedContent = videoFormat != null && (videoFormat.rotationDegrees == 90 || videoFormat.rotationDegrees == 270);
|
||||||
int height = videoFormat != null ? videoFormat.height : 0;
|
int width = videoFormat != null ? (isRotatedContent ? videoFormat.height : videoFormat.width) : 0;
|
||||||
|
int height = videoFormat != null ? (isRotatedContent ? videoFormat.width : videoFormat.height) : 0;
|
||||||
String trackId = videoFormat != null ? videoFormat.id : "-1";
|
String trackId = videoFormat != null ? videoFormat.id : "-1";
|
||||||
|
|
||||||
// Properties that must be accessed on the main thread
|
// Properties that must be accessed on the main thread
|
||||||
@ -1444,6 +1445,7 @@ public class ReactExoplayerView extends FrameLayout implements
|
|||||||
videoTrack.setWidth(format.width == Format.NO_VALUE ? 0 : format.width);
|
videoTrack.setWidth(format.width == Format.NO_VALUE ? 0 : format.width);
|
||||||
videoTrack.setHeight(format.height == Format.NO_VALUE ? 0 : format.height);
|
videoTrack.setHeight(format.height == Format.NO_VALUE ? 0 : format.height);
|
||||||
videoTrack.setBitrate(format.bitrate == Format.NO_VALUE ? 0 : format.bitrate);
|
videoTrack.setBitrate(format.bitrate == Format.NO_VALUE ? 0 : format.bitrate);
|
||||||
|
videoTrack.setRotation(format.rotationDegrees);
|
||||||
if (format.codecs != null) videoTrack.setCodecs(format.codecs);
|
if (format.codecs != null) videoTrack.setCodecs(format.codecs);
|
||||||
videoTrack.setTrackId(format.id == null ? String.valueOf(trackIndex) : format.id);
|
videoTrack.setTrackId(format.id == null ? String.valueOf(trackIndex) : format.id);
|
||||||
videoTrack.setIndex(trackIndex);
|
videoTrack.setIndex(trackIndex);
|
||||||
|
@ -548,15 +548,16 @@ Callback function that is called when video tracks change
|
|||||||
|
|
||||||
Payload:
|
Payload:
|
||||||
|
|
||||||
| Property | Type | Description |
|
| Property | Type | Description |
|
||||||
| -------- | ------- | ------------------------------------- |
|
| -------- | ------- | --------------------------------------------------------------- |
|
||||||
| index | number | index of the track |
|
| index | number | index of the track |
|
||||||
| trackId | string | Internal track ID |
|
| trackId | string | Internal track ID |
|
||||||
| codecs | string | MimeType of codec used for this track |
|
| codecs | string | MimeType of codec used for this track |
|
||||||
| width | number | Track width |
|
| width | number | Track width |
|
||||||
| height | number | Track height |
|
| height | number | Track height |
|
||||||
| bitrate | number | Bitrate in bps |
|
| bitrate | number | Bitrate in bps |
|
||||||
| selected | boolean | true if track is selected for playing |
|
| selected | boolean | true if track is selected for playing |
|
||||||
|
| rotation | number | 0, 90, 180 or 270 rotation to apply to the track (android only) |
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
|
|
||||||
@ -571,6 +572,7 @@ Example:
|
|||||||
height: 1080,
|
height: 1080,
|
||||||
bitrate: 10000,
|
bitrate: 10000,
|
||||||
selected: true,
|
selected: true,
|
||||||
|
rotation: 0,
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user